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.

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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度