Accettend letter and other graphic simbols PHP->JS
Posted
by Kreker
on Stack Overflow
See other posts from Stack Overflow
or by Kreker
Published on 2010-06-10T12:59:59Z
Indexed on
2010/06/10
13:02 UTC
Read the original article
Hit count: 225
I have to read a txt via file php. This file contains some normal so may contains this kind of symbols :
€ é ò à ° % etc
I read the content in php with file_get_contents and transform these for inserenting in SQL database.
$contFile = file_get_contents($pathFile);
$testoCommento = htmlspecialchars($contFile,ENT_QUOTES);
$testoCommento = addslashes($testoCommento);
Now if I have this text for example :
"l'attesa ?é cruciale fino a quando il topo non viene morso dall'?€"
in the database I have this:
l'attesa è cruciale fino a quando il topo non veniene morso dall'€
When I was GETTING the data from the database I use the php function for decode html entites
$descrizione = htmlspecialchars_decode($risultato['descrizione'],ENT_QUOTES);
$descrizione = addslashes($descrizione);
Now I use jasvascript and AJAX for getting the table content and display to an HTML page In the browser instead of getting the correct text (€,è) I have square symbol. I think there is some mess with charset code/decode but never figured out.
The SQL' table is in "utf8_unicode_ci" format and the column in "utf8_general_ci". The content-type of the page is
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Thanks for help me!
© Stack Overflow or respective owner