问题描述
有了这个:
< meta http-equiv =Content-Typecontent =text / html; = utf-8>
IE正常显示
Chrome正常显示
有了这个:
< meta http-equiv =Content-Typecontent =text / html; charset = utf8>
(不包括 - f和8之间)
然后我有一个SQL连接(数据库设置为utf8_unicode_ci或ascii_general_ci)
mysqli_set_charset('utf8')
IE和Chrome在发布结果时会正确显示èéàäö
mysqli_set_charset('utf-8' )
IE和Chrome显示é$或发布结果时
其他浏览器如何?
为什么?
解决方案在 Content-Type
标签,有效的方式是:
< meta http-equiv =Content-Typecontent =text / html; charset = utf-8>
Chrome正确显示的原因是因为它更容易接受错误,而IE需要它
但是它与MySQL不同。他们决定用短名字去。以下是。
您也可以执行以下查询:
SHOW CHARACTER SET LIKE'utf%'
$ b b
编辑:
请确保您使用的字符集与 INSERT
到您的数据库,或者当您再次查看它可能会导致不良效果。
With this:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
IE displays properlyChrome displays properly
With this:
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
(without the - between f and 8)
IE displays èéàä etc. with è$ etc.Chrome displays properly
Then I have a SQL Connection (database setted with utf8_unicode_ci or ascii_general_ci)
mysqli_set_charset('utf8')
IE and Chrome display èéàäö properly when posting the results
mysqli_set_charset('utf-8')
IE and Chrome display è$ etc. or ????? when posting the results
How about the other browsers?Why?
解决方案 In the Content-Type
meta tag, the valid way is:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
The reason Chrome displays properly is because it is more accepting of errors in this case whereas IE requires it to be written properly.
However it's different with MySQL. They decided to go with the short names. Here is a list of supported character sets. This is something done server-side, so it won't matter what browser you are using.
You can also execute the following query:
SHOW CHARACTER SET LIKE 'utf%'
Edit:
Make sure that you are using the same character set to INSERT
into your database or this could cause undesired effects when you go to view it again.
这篇关于MySQL的UTF8 Chrome,UTF8的IE,但HEADER的UTF8的Chrome和UTF-8的IE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!