[unicode] provide <boost/cuchar.hpp> header?

The C++11 standard library provides a header <cuchar>, with a bit of Unicode support, based on C's <uchar.h>: Macros: __STDC_UTF_16__, __STDC_UTF_32__ Functions: mbrtoc16, c16rtomb, mbrtoc32, c32rtomb The functions provide conversion between char sequences and UTF-16/UTF-32. It would be useful to have a <boost/cuchar.hpp> header so that these functions could be used with existing compilers and standard libraries. Does anyone have an implementation of these functions they would be willing to contribute? --Beman

From: Beman Dawes <bdawes@acm.org>
The C++11 standard library provides a header <cuchar>, with a bit of Unicode support, based on C's <uchar.h>:
Macros: __STDC_UTF_16__, __STDC_UTF_32__
Functions: mbrtoc16, c16rtomb, mbrtoc32, c32rtomb
The functions provide conversion between char sequences and UTF-16/UTF-32.
It would be useful to have a <boost/cuchar.hpp> header so that these functions could be used with existing compilers and standard libraries.
Does anyone have an implementation of these functions they would be willing to contribute?
They should be trivially implementable using mbsrtowcstype of functions and boost::locale::conv::utf_to_utf (header only) Also note, the only compiler that actually provides char16_t and char32_t at this point is GCC... So meanwhile they would be quite useless. (No, MSVC10 does not provide them they are typedefs(!) and not real types) Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/

On 02/27/2012 02:59 PM, Beman Dawes wrote:
The C++11 standard library provides a header<cuchar>, with a bit of Unicode support, based on C's<uchar.h>:
Macros: __STDC_UTF_16__, __STDC_UTF_32__
Functions: mbrtoc16, c16rtomb, mbrtoc32, c32rtomb
The functions provide conversion between char sequences and UTF-16/UTF-32.
It would be useful to have a<boost/cuchar.hpp> header so that these functions could be used with existing compilers and standard libraries.
Does anyone have an implementation of these functions they would be willing to contribute?
In the C version of the header, it provides the following typedefs: typedef _Char32_t char32_t; typedef _Char16_t char16_t; It could be useful to use that header to provide the char32_t types if they don't exist. The problem is that in C++, char32_t is a keyword, so you can't have boost::char32_t. It can either be ::char32_t or boost::char32.
participants (3)
-
Artyom Beilis
-
Beman Dawes
-
Mathias Gaunard