douqianmin5367 2012-04-15 21:38
浏览 55
已采纳

Dreamweaver utf-8编码的php页面在IE和Chrome中显示错误的中文字符,在FF中更正

I have an issue with character encoding:

I have this page: http://www.studiomille.jp/class/
(its in japanese but the character in question is from chinese i think)

FF shows it correctly, IE (all versions) and Chrome doesn't (sorry larger screenshots):

  • FF Screenshot: FF Screenshot
  • IE Screenshot: IE Screenshot

(there are other character that are different throughout the site, this is just one example)

Everything is set to UTF-8:
* PHP sends header: Content-Type:text/html; charset=UTF-8
* PHP starts with: mb_language('uni'); mb_internal_encoding('UTF-8');
* meta tag: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
* all files are saved with UTF-8 encoding with DreamWeaver CS3
* the same font is used in all the browsers.

On that page nothing comes from the db, everything is hard coded.

The site has the same behavior on my localhost too.

So why only FF gets it right and how can I make it work on IE also?

  • 写回答

1条回答 默认 最新

  • dongzhaiqiang6108 2012-04-15 23:43
    关注

    These two characters are variants of each other but share the same code point.
    See http://en.wiktionary.org/wiki/将.

    The variant showing up in Firefox is the Japanese Kanji variant, the "incorrect" one is the Chinese Hanzi variant. If all you have is the code point/UTF-8 encoded character, it's ambiguous which variant should be rendered. As a great example, try copying the two different characters from the aforelinked Wiktionary entry and paste them into a different application. You'll likely end up pasting a different variant than you copied for one of them.

    To solve this, you can hint the language to the browser. Taken from the Wiktionary entry:

    <span lang="zh-Hans" xml:lang="zh-Hans">将</span>
    <font lang="ja" xml:lang="ja">将</font>
    

    (Not that you should be using the <font> tag anymore...)

    This is still no guarantee how the character will be rendered, but if the browser takes the hint, it should work. You should be able to set the lang for the whole document, instead of each character individually.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧