What does `lt;cuchargt;` provide, and where is it documented?(`lt;cuchargt;` 提供了什么,它在哪里记录?)
问题描述
新的 C++11 标准提到了一个头文件 ,大概类似于 C99 的 .
The new C++11 standard mentions a header <cuchar>, presumably in analogy to C99's <uchar.h>.
现在,我们知道 C++11 带来了新的字符类型和文字 专为 UTF16 和 UTF32 设计,但我认为该语言实际上不会包含将(依赖于系统的)窄多字节编码转换为 Unicode 编码之一的函数.但是,我刚刚看到了 <cuchar> 的标题概要,其中提到了函数 mbrtoc16/c16rtombr 和 mbrtoc32/c32rtombr 似乎就是这样做的.
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.
不幸的是,除了标题概要之外,标准没有说明这些功能.这些函数在哪里定义,它们真正做什么,我在哪里可以阅读更多关于它们的信息?这是否意味着现在可以完全使用标准 C++ 使用正确的 Unicode,而无需任何额外的库?
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?
推荐答案
这些在 2005 年的 WG21 论文 但最终标准中没有该描述.它们记录在 ISO/IEC 19769:2004(支持新字符数据类型的编程语言 C 的扩展)(draft),C++11 标准参考.
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);
函数分别在多字节字符和 UTF-16 或 UTF-32 字符之间进行转换,类似于 mbrtowc.没有不可重入的版本,老实说,谁需要它们?
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?
这篇关于`<cuchar>` 提供了什么,它在哪里记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:`<cuchar>` 提供了什么,它在哪里记录?
基础教程推荐
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- CString 到 char* 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
