我使用mysql_query("SET NAMES 'utf8'");
将文本插入/更新到utf8_unicode_ci编码的表
在mysql表中,它看起来像"ş,ğ,ü"。但当我用PHP打印时,
看起来像"� ??"。
我试着添加
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
但没有起作用。
如何在页面上正确显示unicode字符?
感谢
您应该使用:
mysql_set_charset('utf8');
而不是
mysql_query("SET NAMES 'utf8'")
我建议在PHP中也设置头
header('Content-Type: text/html; charset=UTF-8');
PHP的UTF-8设置:
ini_set("mbstring.language", "Neutral");
ini_set("mbstring.internal_encoding", "UTF-8");
ini_set("mbstring.encoding_translation", "On");
ini_set("mbstring.http_input", "auto");
ini_set("mbstring.http_output", "UTF-8");
ini_set("mbstring.detect_order", "auto");
ini_set("mbstring.substitute_character", "none");
ini_set("default_charset", "UTF-8");
ini_set("mbstring.func_overload", 7);
setlocale(LC_TIME, "en_US.UTF-8");