如何处理跨多个网络浏览器的不同编码
我有一个包含法语的网站,带有重音符号“é、è、à、...”。
该网站在 Chrome 中显示正常,但这些符号在 Firefox 中显示混乱。我使用 C# StreamWriter 生成了这些页面。我选择编码“UTF8”。
我也尝试过 ISO-8859-1 和 ASCII,但收效甚微。
有没有办法确定我可以使用哪种编码在每个浏览器中都可以正常显示?
编辑 *
好吧,这是我所做的事情的总和,
我用默认编码读取了文件
我用 StreamWriter 将其写回驱动器
StreamWriter sw = new StreamWriter(path, false, Encoding.GetEncoding("ISO-8859-1"));
在每个页面中都有一个元标记
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
我的两个浏览器都设置为 Encoding -> ISO-8859-1
我在 Firefox 中仍然遇到错误,而 Chrome 显示正常。
如果您想查看该页面,请访问
I have a website which contains french, with accents "é, è, à,...".
The website displays fine in chrome but those symbols are messed up in firefox. I generated these pages with C# StreamWriter. I choose Encoding "UTF8".
I've tried with ISO-8859-1 and ASCII too with little succes.
Is there a way to figure out which encoding I can use that will display fine in every browser?
EDIT *
Ok here is a sum of what I've did
I read the file with Default encoding
I write it back to the drive with a StreamWriter
StreamWriter sw = new StreamWriter(path, false, Encoding.GetEncoding("ISO-8859-1"));
In every single page there is a meta tag
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
Both of my browsers are set to Encoding -> ISO-8859-1
I still get errors in Firefox and Chrome displays fine.
If you want to see the page its
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将 Content-Type 标头(或等效的元标记)设置为用于生成文档的编码,以便浏览器可以可靠地解码您的内容。这是一篇解释详细信息的文章。对于国际字符,UTF-8 是一个不错的编码选择。
如果您不明白为什么这是必要的,或者字符编码是什么; 去阅读这篇文章。
You should set the Content-Type header (or the equivalent meta tag) to the encoding you used to generate the document, so the browser can reliably decode your content. Here is an article explaining the details. For international characters, a good choice of encoding is UTF-8.
If you don't feel you understand why this is necessary, or what the character encoding is; go read this article.