UTF-8 或 UTF-16 或 UTF-32 或 UCS-2 [英] UTF-8 or UTF-16 or UTF-32 or UCS-2

查看:21
本文介绍了UTF-8 或 UTF-16 或 UTF-32 或 UCS-2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个新的 CMS,但想要设计它来满足我未来的所有需求,比如多语言内容,所以我认为 Unicode (UTF-8) 是最好的解决方案

I am designing a new CMS but want to design it to fit all my future needs like Multilingual content so i was thinking Unicode (UTF-8) is the best solution

但是通过一些搜索我得到了这篇文章

But with some search i got this article

http://msdn.microsoft.com/en-us/library/bb330962%28SQL.90%29.aspx#intlftrql2005_topic2

所以我现在很困惑现在使用什么UTF-8/UTF-16/UTF-32/UCS-2

So i am now confused what to use now UTF-8 / UTF-16 / UTF-32 / UCS-2

哪个更适合多语言内容和性能等

which is better for Multilingual content and performance etc.

PS:我使用的是 Asp.net 和 C# 以及 SqlServer 2005

提前致谢

推荐答案

这不是问题,因为您说:

This is a non-issue because you say:

我正在使用 Asp.net 和 c# 以及 SqlServer 2005

i am using Asp.net and c# and SqlServer 2005

SqlServer 在一些地方(ntext、nvarchar、nchar)使用 UTF-16,在一些以 XML 为中心的地方使用 UTF-8,而你没有做任何奇怪的事情.

SqlServer uses UTF-16 in some places (ntext, nvarchar, nchar) and UTF-8 in a few XML-centric places, without you doing anything weird.

C# 在其所有字符串中使用 UTF-16,并在处理流和文件时使用工具进行编码,这些流和文件使我们...

C# uses UTF-16 in all its strings, with tools to encode when it comes to dealing with streams and files that bring us onto...

ASP.NET 默认使用 UTF-8,很难想到它不是一个好的选择(即使是亚洲语言,这些语言的文本简洁加上名称和符号的事实在 HTML、CSS、javascript 中具有特殊含义的大多数 XML 应用程序和您将发送的其他流都在 U+0000 到 U+007F 范围内,这使得 UTF-16 在该范围内优于 UTF-8 的优势不如使用亚洲语言的纯文本).

ASP.NET uses UTF-8 by default, and it's hard to think of a time when it isn't a good choice (even with Asian languages, the textual concision of such languages combined with the fact that the names and symbols with special meaning in HTML, CSS, javascript, most XML applications and other streams you will be sending are from the range U+0000 to U+007F, makes the advantage of UTF-16 over UTF-8 in that range less significant than with plain text of Asian languages).

SqlServer 和 C# 的 UTF-16 和 ASP.NET 在读取和写入时使用的 UTF-8 之间的对话是使用默认设置为您完成的,但由于这是您可以轻松更改的一位,因此,我的答案是使用 UTF-8.实际上,您将混合使用 -8 和 -16,但大多数时候您不会注意到(您是否注意到您已经这样做了).

The talking between the UTF-16 of SqlServer and C# and the UTF-8 that ASP.NET does by in reading and writing, is done for you with default settings, but since this is the one bit you can readily change, my answer therefore would be to use UTF-8. Really you'll be using a mixture of -8 and -16, but you won't notice most of the time (have you noticed that you've already been doing so).

SQL Server 的宽容度稍差一些,因为许多过时的示例将预期供人类使用的文本放入 varchar、text 或 char 字段中.将这些纯粹用于代码(例如,所有 ISO 国家/地区代码都在 char(2) 范围内,因此 nchar(2) 只会浪费空间),并且只有 nvarchar、ntext 和 nchar 用于人们而不是机器将读取和写入的内容.

SQL Server is a bit less forgiving, if only because a lot of outdated examples have text expected for human consumption being put in varchar, text or char fields. Use these purely for codes (e.g. all ISO country codes are in the range of char(2), so nchar(2) would just waste space), and only nvarchar, ntext and nchar for things people rather than machines will read and write.

这篇关于UTF-8 或 UTF-16 或 UTF-32 或 UCS-2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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