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

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.

    点赞 打赏 评论

相关推荐 更多相似问题