I am using code igniter framework and added the header("Content-Type: text/html; charset=UTF-8"); in server side as well as the < meta charset="UTF-8">, < meta http-equiv="Content-type" content="text/html; charset=UTF-8"> in client side code. When I type a french character with accent as input it keeps saving as weird characters like copyright symbol and weird A's. Im using javascript to encode the input and it encodes correctly into & #224; etc. but when I try decoding it with innerHTML it doesnt output the correct characters.
You should use the htmlspecialchars()
function to convert UTF-8 to HTML entities.
Also make sure you've set your HTML document to UTF-8 using <meta charset="UTF-8">
.
-
i dont think htmlspecialchars() will do french conversions. also i need to use a javascript equivalence of htmlentities() as I cant embed php in a javascript function. – Aditya Oct 9 '13 at 2:58
-
Make sure that your text editor is set to utf-8. I had the same issue using Nusphere, it was automatticaly using another charset (like Windows-....) after deleting file and created another with UTF-8 settings, it worked ok.
-
i checked encoding of the php file in notepad++ and it says UTF-8 without BOM – Aditya Oct 9 '13 at 2:56
Thanks for your answers I found the issue, it was because I was not passing 'UTF-8' as a parameter while calling htmlentities() in php code. there was no need for me to try to encode it in javascript.