有什么原因不使用UTF-8,16,等等一切吗? [英] Is there any reason not to use UTF-8, 16, etc. for everything?

查看:209
本文介绍了有什么原因不使用UTF-8,16,等等一切吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道网络大多是标准化的UTF-8最近,我只是想知道是否有任何地方使用UTF-8将是一件坏事。我听说过UTF-8,16等可能会使用更多的空间,但是到底它是可以忽略的。

I know the web is mostly standardizing towards UTF-8 lately and I was just wondering if there was any place where using UTF-8 would be a bad thing. I've heard the argument that UTF-8, 16, etc may use more space but in the end it has been negligible.

此外,在Windows程序,

Also, what about in Windows programs, Linux shell and things of that nature -- can you safely use UTF-8 there?

推荐答案

如果UTF-32可用,优先于其他版本进行处理。

If UTF-32 is available, prefer that over the other versions for processing.

如果您的平台支持UTF-32 / UCS-4 Unicode,那么压缩版本UTF-8和UTF-16可能会更慢,每个字符(字符序列)的字节数,这使得不可能通过索引在字符串中进行直接查找,而UTF-32对每个字符使用32位flat,从而加快了一些字符串操作。

If your platform supports UTF-32/UCS-4 Unicode natively - then the "compressed" versions UTF-8 and UTF-16 may be slower, because they use varying numbers of bytes for each character (character sequences), which makes impossible to do a direct lookup in a string by index, while UTF-32 uses 32 bit "flat" for each character, speeding up some string operations a lot.

当然,如果你在一个非常受限制的环境中编程,比如嵌入式系统,可以肯定只有ASCII或ISO 8859-x字符, ,那么您可以选择这些字符集的效率和速度。但一般来说,请使用 Unicode转换格式

Of course, if you are programming in a very restricted environment like, say, embedded systems and can be certain there will be only ASCII or ISO 8859-x characters around, ever, then you can chose those charsets for efficiency and speed. But in general, stick with the Unicode Transformation Formats.

这篇关于有什么原因不使用UTF-8,16,等等一切吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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