`<cuchar>` 提供了什么,它在哪里记录?

What does `lt;cuchargt;` provide, and where is it documented?(`lt;cuchargt;` 提供了什么,它在哪里记录?)

本文介绍了`<cuchar>` 提供了什么,它在哪里记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的 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/c16rtombrmbrtoc32/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?

这篇关于`&lt;cuchar&gt;` 提供了什么,它在哪里记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:`&lt;cuchar&gt;` 提供了什么,它在哪里记录?

基础教程推荐