Hi,
I have this html page with charset set to "utf-8", and it is important that that charset remains in that setting.
How can I obtain a right encode using javascript even if the charset isn't iso-8859-1?
Using PHP seems that the problem it can be resolved with utf8_encode function, but in js I have tried many things without success.
Now I post here a simple code to explain better the matter. Can you help me please?
(If you not able to see the "à" charachter within the code, it is an "a grave");
The strange result of encodeURIComponent is "%EF%BF%BD".Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title></title> <script type="text/javascript"> alert(encodeURIComponent("à")); // alert('<?php echo utf8_encode("à") ?>'); </script> </head> <body> </body> </html>
I hope you can help me to resolve this problem, because I met that one in many occasions during programming...
many thanks!




Reply With Quote


Bookmarks