【问题标题】:Mysql utf32_unicode_ci and html charset utf-8 used, but character � appearMysql utf32_unicode_ci 和 html charset utf-8 使用了,但是出现字符 �
【发布时间】:2012-07-11 01:51:14
【问题描述】:

我在 MySQL 字段中有一些法语文本,在 PHPMyAdmin 下正确显示:

mentionné

该字段编码为utf32_unicode_ci。 (这是一个varchar(500), utf32_unicode_ci)。

但调用 PHP 脚本调用此参数并以 utf-8 编码的 html 输出返回:

mentionn�

这是我的 php html 标头的摘录:

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="fr-FR">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

我该如何解决这个问题?

【问题讨论】:

标签: mysql html encoding


【解决方案1】:

除了数据库编码,请务必检查以下内容:

  • 文件(js/php)的utf8编码(在ultra-edit下,F12:另存为UTF8-NOBOM)
  • utf8 html内容:&lt;meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8"&gt;
  • 你的数据库连接的utf8:SET character_set_connection = 'utf8'
  • 你的查询结果的utf8:SET character_set_results = 'utf8'
  • 您的数据库客户端的utf8:SET character_set_client = 'utf8'
  • 你的mysql表的utf8:ALTER TABLE table CONVERT TO CHARACTER SET utf8;
  • 你的数据库服务器的utf8:SET character_set_database = 'utf8'SET character_set_server = 'utf8'
  • 在某些情况下,当硬编码值需要编码时,必须在文件中强制使用 utf8。例如,您需要在文件顶部添加注释,例如 charset=utf-8,以便超级编辑或您喜欢的编辑器可以检测到它。

rgds.

ps:我不知道 utf32 但不知怎么的逻辑应该是一样的

【讨论】:

  • 是的,mysql_set_charset('utf8', $con);成功了。谢谢。
猜你喜欢
  • 2020-10-26
  • 1970-01-01
  • 2018-09-24
  • 2011-09-26
  • 1970-01-01
  • 2011-02-26
  • 2013-07-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多