【发布时间】:2019-11-17 16:51:13
【问题描述】:
我需要将 csv 文件中的列名存储到 mysql DB 中,在 PHP 中我曾经将字符串转换为 utf8_encode 格式。它不适用于某些字符串,
$name = "Téléphone"
echo utf8_encode($name); // it works
output : Téléphone
$name = "Etat œuvre"
echo utf8_encode($name); // it does not works
output : Etat Å?uvre
用于测试:
echo bin2hex($name);
output: 45746174209c75767265
【问题讨论】:
-
utf8_encode是一个很没用的函数。它绝对不会像你想的那样做。 -
utf8_encode从 ISO-8859-1 转换为 UTF-8。 ISO-8859-1 中不存在字符“–”,因此不清楚它最初是如何存在的。您的源代码是如何编码的?如有疑问,请联系echo bin2hex('Etat œuvre')。 -
首先回答我上面的问题。
-
@deceze 它打印 45746174209c75767265
标签: php encoding utf-8 character-encoding