如何强制互联网浏览器使用元标记中给出的编码? [英] How to enforce internet explorer to use encoding given in meta tag?

查看:131
本文介绍了如何强制互联网浏览器使用元标记中给出的编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在准备一个混合的英语和阿拉伯语内容的演示html页面。
基本上它包含一个左边有英语短语的小表,右边有阿拉伯语翻译。

I'm trying to prepare a demo html page with mixed english and arabic content. Basically it contains a small table with english phrases on the left, and the arabic translation on the right side.

因为我不懂阿拉伯语,我从 Unicode参考中取得了阿拉伯字母表的前三个字符。

Because I don't understand arabic, I took the first three characters of the arabic alphabet from the Unicode reference.

使用字符实体(ابت)首次尝试:it works(display:ا&#x0628 ;ت)。

First attempt, using the character entities (ا ب ت): it works (display: ا ب ت).

我试图在文档中直接输入阿拉伯文字符。要启用此功能,我将文档另存为UTF-8,并为内容类型添加了元标记。

The I tried to enter the arabic characters directly in the document. To enable this, I saved the document as UTF-8 and added the meta tag for the content type.

在Internet Explorer(7) §Ø¨Øª

Displaying this document in Internet Explorer (7) shows garbage: ا ب ت

手动切换IE使用UTF-8(菜单视图 - >视图 - > Unicode)使IE显示字符相关。但是一旦文档重新加载,垃圾将再次出现。

Manually switching IE to use UTF-8 (Menu "View -> View -> Unicode") makes IE show the characters correclty. But as soon as the document gets reloaded, the garbage appears again.

<html>
  <head>
  <meta content="content-type" content="text/html; charset=utf-8">
  </head>
  <body>
    <table width="95%" border="1">
      <colgroup><col width="50%" /><col width="50%" /></colgroup>
      <tbody>
        <tr>
          <th>English</th><th>Arabic</th>
        </tr>
        <tr>
          <td>Test phrase</td>
          <td dir="rtl">ا ب ت</td>
        </tr>
      </tbody>
    </table>
  </body>
</html>

使用Firefox测试显示正确的阿拉伯字母。 (但是方向rtl的解释是不同的:IE显示文本右对齐,Firefox向左对齐。)

Testing with Firefox shows the correct arabic letters. (But the interpretation of the direction "rtl" is different: IE show the text right aligned, Firefox left aligned.)

任何提示如何说服IE使用编码在文档中给出?

Any hints how to convince IE to use the encoding given in the document?

这是本地存储的html文件的效果吗?编辑此StackOverflow条目时,我观察到

Is this an effect of locally stored html files? When editing this StackOverflow entry, I observe


  • 阿拉伯字符按预期呈现,

  • 编码在菜单中自动切换到Unicode(UTF-8),

  • ,html的源不包含内容类型的元标记。

推荐答案

看起来您的元标记中有小的拼写错误。应该说:

Looks like there is a small typo in your meta tag. It should say:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      ^ you had 'content' here,   and forgot to close the tag here ^

没有IE7方便,所以不能检查,如果这是原因。这两个版本在IE8上工作良好

I don't have IE7 handy, so can't check if that's the reason. Both versions work fine on IE8

这篇关于如何强制互联网浏览器使用元标记中给出的编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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