且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 windows-1252 而不是 UTF-8 有什么问题

更新时间:2023-11-27 14:08:52

Windows 1252 是众多固定大小字符集之一.Mac 有自己的一套.欧洲各地和世界其他一些地区都有一些 ISO.它们中的大多数都有细微的变化.

Windows 1252 is one of the many many fixed size character sets. Mac has its own set. there are a few ISO for various parts of the Europe and for some other parts of the world. Most of them have slight variations.

好处是你有一个固定大小的字符,这意味着 1 个字符 = 1 个字节,无论如何.

The good point is that you have a fixed-size character, meaning 1 character = 1 byte no matter what.

缺点是:

  • 有些人可能没有安装你的编码
  • 有些人可能使用稍微不同的编码,导致问题很少,不明显,但从长远来看非常难看
  • 您只能支持几种语言

这包括您想要引用的任何引用.在 windows-1252 中你不能显示俄语、希腊语、波兰语...

That include any citation you would like to make. In windows-1252 you can't display russian, greek, polish ...

UTF-8 是 1+ 字节的 unicode 表示的标准编码.它可以代表您可能遇到的绝大多数字符,尽管它是为基于拉丁语的语言设计的,因为其他语言占用更多存储空间.

UTF-8 is the standard encoding for unicode representation on 1+ bytes. It can represent a very large majority of the characters you may encounter, although it is designed for latin-based languages, as other languages take more storage space.

它用于 XML、JSON 和您可能找到的大多数类型的 Web 服务.当您不知道要使用什么编码时,这是一个很好的默认值.它允许限制编码问题的数量,例如我虽然你使用的是 Latin-1/不,我使用的是 latin-9,但后来 Mac 上的这个人使用了 Roman".如果您有超过 1 个人在处理网站的内容,他们的平台上可能有不同的编码,因此您的内容可能会在某些时候混乱.

It in used in XML, JSON, and most types of web services you may find. It is a good default when you don't know what encoding to use. It allows to limit the number of encoding issues, such as "I though you were in Latin-1 / No, I was using latin-9, but then this guy on mac used Roman". If you have more than 1 people working on the content of the website, they may have different encodings on their plateforme, and therefore your content may be messed up at some point.

据我所知,UTF-8 是唯一一种无需讨论即可轻松标准化人与人之间使用的编码的方法.

UTF-8 is, as far as I know, the only way to easily standardize the encoding used between people without discussion.

典型的例子是,如果你的网站是用 windows1252 编码的,而新开发者有一个 mac,你可能会遇到麻烦.

Typical example is, if your website is encoded in windows1252, and the new dev has a mac, you'll probably be in trouble.