是wchar_t的需要UNI code支持? [英] Is wchar_t needed for unicode support?

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

问题描述

wchar_t的键入所需的UNI code支持?如果没有,那么这是什么类型的多字节的地步?为什么要使用wchar_t的时,你可以用完成字符

Is the wchar_t type required for unicode support? If not then what's the point of this multibyte type? Why would you use wchar_t when you could accomplish the same thing with char?

推荐答案

从技术上说,没有。单向code是一个标准,定义了code点和它不要求一个特定的编码

No.

Technically, no. Unicode is a standard that defines code points and it does not require a particular encoding.

所以,你可以使用UNI code用UTF-8编码,然后一切都适合字符对象的一个​​或一个短序列,它会即使仍然是空终止的。

So, you could use unicode with the UTF-8 encoding and then everything would fit in a one or a short sequence of char objects and it would even still be null-terminated.

使用UTF-8和UTF-16的问题是, S [I] 不一定是一个性格更多的,它可能是只是一块一个,而具有足够宽字符可以preserve的抽象S [I] 是一个字符,寿它不会使的字符串的固定长度在各种转变。

The problem with UTF-8 and UTF-16 is that s[i] is not necessarily a character any more, it might be just a piece of one, whereas with sufficiently wide characters you can preserve the abstraction that s[i] is a single character, tho it does not make strings fixed-length under various transformations.

32位整数至少有足够宽,解决了code点的问题,但他们仍然不处理角落的情况下,例如,upcasing东西可以改变的字符数。

32-bit integers are at least wide enough to solve the code point problem but they still don't handle corner cases, e.g., upcasing something can change the number of characters.

因此​​,原来的 X [I] 问题不完全甚至char32_t解决,其他的编码做出错误的文件格式。

So it turns out that the x[i] problem is not completely solved even by char32_t, and those other encodings make poor file formats.

您隐含的点的话,是相当有效的: wchar_t的是失败,部分原因是因为Windows使得它只有16位,部分是因为它并没有解决所有问题并且是用字节流的抽象可怕的是不相容的。

Your implied point, then, is quite valid: wchar_t is a failure, partly because Windows made it only 16 bits, and partly because it didn't solve every problem and was horribly incompatible with the byte stream abstraction.

这篇关于是wchar_t的需要UNI code支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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