`` 提供什么,它在哪里记录?
新的 C++11 标准提到了一个标头
,大概类似于 C99 的
。
现在,我们知道 C++11 带来了新的字符类型和文字 专门为 UTF16 和 UTF32 设计,但我认为该语言实际上不会包含将(依赖于系统的)窄多字节编码转换为其中一种 Unicode 编码的函数。但是,我刚刚发现
的标题概要,其中提到了函数 mbrtoc16
/c16rtombr
和 mbrtoc32
/c32rtombr
似乎就是这样做的。
不幸的是,除了标头概要之外,该标准对这些函数只字未提。这些函数在哪里定义的,它们的真正作用是什么,我在哪里可以阅读有关它们的更多信息?这是否意味着现在可以完全通过标准 C++ 使用正确的 Unicode,而不需要任何额外的库?
The new C++11 standard mentions a header <cuchar>
, presumably in analogy to C99's <uchar.h>
.
Now, we know that C++11 brings new character types and literals that are specifically designed for UTF16 and UTF32, but I didn't think the language would actually contain functions to convert the (system-dependent) narrow multibyte encoding to one of the Unicode encodings. However, I just came across the header synopsis for <cuchar>
that mentions functions mbrtoc16
/c16rtombr
and mbrtoc32
/c32rtombr
that seem to do just that.
Unfortunately, the standard says nothing about those functions beyond the header synopsis. Where are those functions defined, what do they really do and where can I read more about them? Does this mean that one can use proper Unicode entirely with standard C++ now, without the need for any extra libraries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
2005 年的 WG21 论文 但该描述并未出现在最终标准中。它们记录在 ISO/IEC 19769:2004(用于支持新字符数据类型的编程语言 C 的扩展)中 (draft),C++11 标准引用的内容。
文本太长,无法在此处发布,但这些是签名:
这些函数分别在多字节字符和 UTF-16 或 UTF-32 字符之间进行转换,类似于
mbrtowc
。没有不可重入的版本,老实说,谁需要它们?These were described in a WG21 paper from 2005 but the description is not present in the final standard. They are documented in ISO/IEC 19769:2004 (Extensions for the programming language C to support new character data types) (draft), which the C++11 standard refers to.
The text is too long to post here, but these are the signatures:
The functions convert between multibyte characters and UTF-16 or UTF-32 characters, respectively, similar to
mbrtowc
. There are no non-reentrant versions, and honestly, who needs them?我所知道的最好的文档可能是 n1326 ,将TR19769添加到C标准库的提议[编辑:虽然看了一下,R. Martinho Fernandes引用的N1010似乎几乎相同]。
Probably the best documentation of which I'm aware is in n1326, the proposal to add TR19769 to the C standard library [Edit: though looking at it, the N1010 that R. Martinho Fernandes cited seems to have pretty much the same].