`` 提供什么,它在哪里记录?

发布于 2024-12-06 18:51:10 字数 590 浏览 1 评论 0原文

新的 C++11 标准提到了一个标头 ,大概类似于 C99 的

现在,我们知道 C++11 带来了新的字符类型和文字 专门为 UTF16 和 UTF32 设计,但我认为该语言实际上不会包含将(依赖于系统的)窄多字节编码转换为其中一种 Unicode 编码的函数。但是,我刚刚发现 的标题概要,其中提到了函数 mbrtoc16/c16rtombrmbrtoc32 /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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

原野 2024-12-13 18:51:10

2005 年的 WG21 论文 但该描述并未出现在最终标准中。它们记录在 ISO/IEC 19769:2004(用于支持新字符数据类型的编程语言 C 的扩展)中 (draft),C++11 标准引用的内容。

文本太长,无法在此处发布,但这些是签名:

size_t mbrtoc16(char16_t * pc16, const char * s, size_t n, mbstate_t * ps);
size_t c16rtomb(char * s, char16_t c16, mbstate _t * ps);
size_t mbrtoc32(char32_t * pc32, const char * s, size_t n, mbstate_t * ps);
size_t c32rtomb(char * s, char32_t c32, mbstate_t * ps);

这些函数分别在多字节字符和 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:

size_t mbrtoc16(char16_t * pc16, const char * s, size_t n, mbstate_t * ps);
size_t c16rtomb(char * s, char16_t c16, mbstate _t * ps);
size_t mbrtoc32(char32_t * pc32, const char * s, size_t n, mbstate_t * ps);
size_t c32rtomb(char * s, char32_t c32, mbstate_t * ps);

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?

灼痛 2024-12-13 18:51:10

我所知道的最好的文档可能是 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].

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文