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>` 提供了什么,它在哪里记录?
基础教程推荐
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- Windows Media Foundation 录制音频 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01