`< cuchar>`提供什么,它在哪里记录? [英] What does `<cuchar>` provide, and where is it documented?

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

问题描述

新的C ++ 11标准提到一个标头< cuchar> ,大概是类似于C99的< uchar.h& code>。



现在,我们知道C ++ 11带来新字符类型和字面值,这是为UTF16和UTF32专门设计的,但我不认为该语言实际上包含将(系统相关的)窄多字节编码转换为一个的Unicode编码。但是,我刚刚遇到< cuchar> 的标题摘要提到函数 mbrtoc16 / c16rtombr mbrtoc32 / c32rtombr

不幸的是,该标准没有说明这些功能,除了标题大纲。这些功能在哪里定义,他们真正做什么,我在哪里可以阅读更多关于他们?这是否意味着现在可以使用标准C ++正确使用Unicode,而不需要任何额外的库?

解决方案

2005年WG21文件中进行了说明但是描述不存在于最终标准中。它们记录在ISO / IEC 19769:2004(编程语言C的扩展以支持新的字符数据类型)( draft )。C / 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字符之间进行转换, code> mbrtowc 。没有不可重入的版本,老实说,谁需要他们?


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?

解决方案

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?

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆