【发布时间】:2013-03-22 02:19:35
【问题描述】:
我将São Tomé and Príncipe 存储在 MySQL 数据库中。
它在我的网页上显示为S�o Tom� and Pr�ncipe
是否可以直接从数据库中正确显示?
我的 MySQL 类型是 MyISAM,排序规则是 utf8_general_ci
我的网页字符集是<meta charset="utf-8">
字段类型设置为varchar(30),字段排序规则与表utf8_general_ci相同
PHP 功能测试
utf8_decode() 将字符转换为S?o Tom? and Pr?ncipe
htmlspecialchars_decode() 将字符转换为S�o Tom� and Pr�ncipe
html_entity_decode() 将字符转换为 S�o Tom� and Pr�ncipe
quoted_printable_decode() 将字符转换为S�o Tom� and Pr�ncipe
htmlentities()返回空白结果
感谢@SAEVEN
在我的查询 SELECT 之前运行它
mysqli_query($GLOBALS['db_link'], "SET NAMES 'utf8'");
【问题讨论】:
-
你设置的编码类型是什么?
-
@H.Ferrence 谢谢,我刚才看到了。唯一想到的另一件事是臭名昭著/臭名昭著的“BOM”。
-
您的文件是否设置为
with或withoutBOM?我已经回答了很多与您相关的问题。 -
这是
byte order mark参见有关该主题的 Wiki > en.wikipedia.org/wiki/Byte_order_mark - 我有一个客户的网站,只是讨厌没有它。