如何在浏览器中强制使用UTF-8编码?

时间:2023-01-06 07:35:51

I have page which encoding is declared with

我有声明编码的页面

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

But when I enter the page another encoding (ISO) is chosen in browser. I have tried to set encoding by PHP method

但是当我进入页面时,在浏览器中选择了另一种编码(ISO)。我试图通过PHP方法设置编码

header('Content-type: text/html; charset=utf-8');

But it also didn't help. All source files are encoded in UTF-8 without BOM. The only solution which I tried and it had worked was setting encoding in .htaccess file by adding AddDefaultCharset UTF-8 line, but then another pages on the server were not displayed correctly. How can I solve this problem?

但它也没有帮助。所有源文件都以UTF-8编码,没有BOM。我尝试过的唯一解决方案是通过添加AddDefaultCharset UTF-8行在.htaccess文件中设置编码,但服务器上的其他页面未正确显示。我怎么解决这个问题?

1 个解决方案

#1


7  

Disable default charset:

禁用默认字符集:

AddDefaultCharset Off

#1


7  

Disable default charset:

禁用默认字符集:

AddDefaultCharset Off