Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用JavaScript或HTML更改浏览器字符编码_Html_Encoding_Explorer - Fatal编程技术网

使用JavaScript或HTML更改浏览器字符编码

使用JavaScript或HTML更改浏览器字符编码,html,encoding,explorer,Html,Encoding,Explorer,我使用UTF-8字符集来编写HTML,其中一些文本是希伯来语 我使用下面几行来指定浏览器的语言: <html dir="rtl" lang="he"> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=9"> 一些设置为“编码:自动选择”的浏览器将我的网站识别为希伯来语,并以希

我使用UTF-8字符集来编写HTML,其中一些文本是希伯来语

我使用下面几行来指定浏览器的语言:

<html dir="rtl" lang="he">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=9">

一些设置为“编码:自动选择”的浏览器将我的网站识别为希伯来语,并以希伯来语(Windows)编码查看页面。这使得文本显示为乱码,因为它是UTF-8格式的


如何使用HTML或JavaScript强制所有浏览器使用UTF-8编码并忽略任何其他本地设置?

如果禁用自动选择,则无法覆盖字符编码的浏览器设置。在这种情况下,浏览器给用户最后的话语权;这反映在HTML5草案中,该草案在中描述了第一步:“如果用户明确指示用户代理使用特定编码覆盖文档的字符编码,可以选择以确定的置信度返回该编码并中止这些步骤。”

设置Encoding:Auto-Select启用自动选择,在您的情况下,这使浏览器应用UTF-8,除非HTTP头另有说明。对于给定的数据,如果您在启用“自动选择”时确实遇到了问题,则不可能说出出现了什么问题