是Encoding.UTF8还是Encoding.Unicode? [英] Encoding.UTF8 or Encoding.Unicode?

查看:757
本文介绍了是Encoding.UTF8还是Encoding.Unicode?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Encoding.Unicode 只是UTF-16的名称吗?那么为什么只将它称为Unicode而不是UTF16?

Is Encoding.Unicode just a name for UTF-16? Then why is it called just Unicode instead of UTF16?

编码文档中 Microsoft声明,对于大多数情况和应用程序,应避免使用Encoding.ASCIIEncoding.Default.

In the encoding documentation Microsoft states that for most scenarios and applications you should avoid using Encoding.ASCII and Encoding.Default.

使用 System.Text.Encoding 时.在大多数情况下,我应该使用Encoding.Unicode还是Encoding.UTF8?

推荐答案

它来自Unicode的早期. Unicode 1.0是一种16位编码,因为假定65536个代码点就足够了. Unicode 2.0放弃了此限制,但是包括Microsoft在内的Unicode的早期采用者将其编码命名为Unicode,并且一直存在.

It comes from the early days of Unicode. Unicode 1.0 was a 16 bit encoding as it was assumed that 65536 code points would be sufficient. Unicode 2.0 abandoned this restriction, however early adopters of Unicode, including Microsoft, Named their encoding Unicode and it has stuck.

如今,除非您有特定的(例如,需要与之集成的旧版软件)理由这样做,否则您应该使用UTF-8.

Nowadays you should be using UTF-8 unless you have a specific, eg legacy software you need to integrate with, reason to do so.

这样做的原因是ASCII与UTF-8二进制兼容,并且在那里有很多 ASCII码

The reason for this is that ASCII is binary compatible with UTF-8, and there is a lot of ASCII out there

这篇关于是Encoding.UTF8还是Encoding.Unicode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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