开发者

Accent in javascript and PHP

开发者 https://www.devze.com 2023-01-30 04:17 出处:网络
I got a hard time with accent (hey i\'m french, nobody is perfect !) both problem in php and javascript.. here is the code :

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

精彩评论

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