使用了Mysql utf32_unicode_ci和html字符集utf-8,但字符 出现 [英] Mysql utf32_unicode_ci and html charset utf-8 used, but character � appear

查看:77
本文介绍了使用了Mysql utf32_unicode_ci和html字符集utf-8,但字符 出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 providené

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



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

 提示
pre>

以下是我的php html标题的摘录:

  < html xmlns =http://www.w3.org/1999/xhtmldir =ltrlang =fr-FR> 
< head profile =http://gmpg.org/xfn/11>
< meta http-equiv =Content-Typecontent =text / html; charset = UTF-8/>

如何解决这个问题?

解决方案

除了数据库编码之外,请确保您检查以下内容:




  • utf8编码文件(js / php)(在超编辑下,F12:另存为UTF8-NOBOM)

  • utf8 html内容:< meta HTTP-EQUIV =数据库连接的CONTENT =text / html; charset = utf-8>

  • utf8: SET character_set_connection ='utf8'

  • utf8您的查询结果: SET character_set_results ='utf8'
  • utf8:您的mysql表的 SET character_set_client ='utf8'

  • utf8: ALTER TABLE表您的数据库服务器的CONVERT TO CHARACTER SET utf8;

  • utf8: SET character_set_database ='utf8 ' SET character_set_server ='utf8'

  • 在某些情况下,强制utf8在文件中是必要的当硬编码值需要编码时。您需要在文件顶部添加注释,例如,使用 charset = utf-8 ,因此超编辑或您最喜欢的编辑器可以检测到它。



rgds。



ps:我不知道utf32,但不知何故,逻辑应该相同的


I have some text in French in a MySQL field, which appears correctly under PHPMyAdmin:

mentionné

The field is encoded as utf32_unicode_ci. (It is a varchar(500), utf32_unicode_ci).

but a call to a PHP script calling this parameter and outputing in html encoded in utf-8 returns:

mentionn�

Here is an extract of my php html header:

<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" />

How can I fix this?

解决方案

Please, besides the database encoding, be sure you check the following:

  • utf8 encoding of the FILES (js/php) (under ultra-edit, F12: save as UTF8-NOBOM)
  • utf8 html content: <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
  • utf8 of your db connection: SET character_set_connection = 'utf8'
  • utf8 of your query results: SET character_set_results = 'utf8'
  • utf8 of your db client: SET character_set_client = 'utf8'
  • utf8 of your mysql tables: ALTER TABLE table CONVERT TO CHARACTER SET utf8;
  • utf8 of your db server: SET character_set_database = 'utf8' and SET character_set_server = 'utf8'
  • in some cases, forcing utf8 in file is necessary when hardcoded values need encoding. You would need to add a comment on top of your file for instance, with charset=utf-8, so ultra edit or your favorite editor can detect it.

rgds.

ps: I don't know utf32 but somehow the logic should be the same

这篇关于使用了Mysql utf32_unicode_ci和html字符集utf-8,但字符 出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆