在I / O中使用char16_t和char32_t [英] Using char16_t and char32_t in I/O

查看:154
本文介绍了在I / O中使用char16_t和char32_t的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++ 11引入了 char16_t char32_t 以便于使用UTF-16-和UTF-32-编码的文本字符串。但是< iostream> 库仍然仅支持实现定义的 wchar_t 用于多字节I / O。

C++11 introduces char16_t and char32_t to facilitate working with UTF-16- and UTF-32-encoded text strings. But the <iostream> library still only supports the implementation-defined wchar_t for multi-byte I/O.

为什么未添加对 char16_t char32_t 的支持到< iostream> 库以补充 wchar_t 支持?

Why has support for char16_t and char32_t not been added to the <iostream> library to complement the wchar_t support?

推荐答案

在提案 对标准库的最小Unicode支持(修订版2) 表明,图书馆工作组中仅支持字符串和字符串的新字符类型。编解码器方面。显然,大多数人反对支持iostream,fstream,除codecvt和regex之外的其他方面。

In the proposal Minimal Unicode support for the standard library (revision 2) it is indicated that there was only support among the Library Working Group for supporting the new character types in strings and codecvt facets. Apparently the majority was opposed to supporing iostream, fstream, facets other than codecvt, and regex.

根据距 2006年波特兰会议 LWG致力于完全支持Unicode,但并未打算使用现有库工具的Unicode字符变体来复制该库。我没有找到任何细节,但是我想委员会可能会认为当前的库接口不适合Unicode。一个可能的抱怨可能是它在设计时考虑了固定大小的字符,但是Unicode完全淘汰了这一点,因为Unicode数据可以使用固定大小的代码点,但它不会将字符限制为单个代码点。

According to minutes from the Portland meeting in 2006 "the LWG is committed to full support of Unicode, but does not intend to duplicate the library with Unicode character variants of existing library facilities." I haven't found any details, however I would guess that the committee feels that the current library interface is inappropriate for Unicode. One possible complaint could be that it was designed with fixed sized characters in mind, but Unicode completely obsoletes that as, while Unicode data can use fixed sized code points, it does not limit characters to single code points.

我个人认为没有理由不对各种平台上已经提供的最小支持进行标准化(Windows将UTF-16用于wchar_t,大多数Unix平台使用UTF-32)。更高级的Unicode支持将需要新的库功能,但是在iostream和facet中支持char16_t和char32_t不会妨碍您,但会启用基本的Unicode I / O。

Personally I think there's no reason not to standardized the minimal support that's already provided on various platforms (Windows uses UTF-16 for wchar_t, most Unix platforms use UTF-32). More advanced Unicode support will require new library facilities, but supporting char16_t and char32_t in iostreams and facets won't get in the way but would enable basic Unicode i/o.

这篇关于在I / O中使用char16_t和char32_t的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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