Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
附件字母和其他图形符号PHP->JS_Php_Json - Fatal编程技术网

附件字母和其他图形符号PHP->JS

附件字母和其他图形符号PHP->JS,php,json,Php,Json,我必须通过php文件读取txt。此文件包含一些普通符号,因此可能包含此类符号: € é ò à ° % etc 我用php读取带有文件\u get\u内容的内容,并将这些内容转换为插入SQL数据库 $contFile = file_get_contents($pathFile); $testoCommento = htmlspecialchars($contFile,ENT_QUOTES); $testoCommento = addslashes($testoComme

我必须通过php文件读取txt。此文件包含一些普通符号,因此可能包含此类符号:

€ é ò à ° % etc
我用php读取带有文件\u get\u内容的内容,并将这些内容转换为插入SQL数据库

    $contFile = file_get_contents($pathFile);
    $testoCommento = htmlspecialchars($contFile,ENT_QUOTES);
    $testoCommento = addslashes($testoCommento);
现在,如果我有这个文本,例如: 拉特萨�这是一个非常关键的时刻�€ 在数据库中,我有:

l'attesa è cruciale fino a quando il topo non veniene morso dall'€
当我从数据库中获取数据时,我使用php函数对html实体进行解码

$descrizione = htmlspecialchars_decode($risultato['descrizione'],ENT_QUOTES);
$descrizione = addslashes($descrizione);
现在我使用jasvascript和AJAX获取表内容并显示到HTML页面 在浏览器中,我没有得到正确的文本,而是使用了方形符号。 我认为字符集编码/解码有些混乱,但一直没有弄清楚

SQL'表采用utf8\U unicode\U ci格式,列采用utf8\U general\U ci格式。 页面的内容类型为

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

谢谢你的帮助

addslashes与Unicode不兼容,您应该使用不同的方法来转义字符串中的引号,或者最好切换到使用准备好的语句,而不是将SQL查询构造为字符串

有关详细信息,请访问: