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. :mad: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". I hope you can help me to resolve this problem, because I met that one in many occasions during programming...

many thanks!

AussieJohn
—
2012-10-31T23:47:31Z —
#2

When you're working with files that you think are in UTF-8 it's worth checking that whatever editor you used is actually using UTF-8 to save the files.

When you use encodeURIComponent it will encode the character in to a safe representation for use in URLs, if you are then using decodeURIComponent on a page with the same encoding as where the character was encoded in the first place, it should decode back in to the correct character. If however, you decode it on a page with a different encoding, you might not get the correct character back.