开发者

Accent in javascript and PHP

I got a hard time with accent (hey i'm french, nobody is perfect !) both problem in php and javascript.. here is the code :

in php :

 $message = "";
 $message .= "Bonjour!". "\r\n";
 $message .= "Je désire m'inscrire à la liste d'envoi pour recevoir le bulletin de la Fondation Martin-Matte par courriel.". "\r\n";
 $mess开发者_如何学Goage .= "Merci"."\r\n";
 $message = utf8_encode($message);

the encode function produce : Bonjour!, Je désire ...... not good !

HOW to encode properly a string with accent ?


and in javascript : alert ("l'adresse de courriel : "+ email +" est bien ajouté à la liste d'envoit, merci"); produce a � caracter...

what should i do ???? help


désire is caused by unicode (UTF-8) characters being displayed as ANSI. The � character is caused by ANSI characters (above 127) being displayed as UTF-8. When your PHP outputs UTF-8 character, you should also send a Content-Encoding header to notify the client that the data is UTF-8. It is recommended to output this encoding in the heading of your HTML file as well.

I think you can save javascript files as UTF-8 without problems.


To convert ANSI to UTF-8 or UTF-8 to ANSI, open the file with Notepad and use Save as. this opens a box where it's possible to choose UTF-8 or ANSI.

I did it and my problem was solved in a second.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜