Topic: char32_t, u32string & co: What for?


Author: "Thomas J. Gritzan" <phygon_antispam@gmx.de>
Date: Sat, 4 Apr 2009 09:50:39 CST
Raw View
We will have Unicode (utf8, utf16 and utf32) character types, strings
and string literals in the next standard. Nice.

I just skimmed through the N2857 working paper and found that we can
hardly do anything with this Unicode strings. Many classes that work on
strings are specified/typedef'd for char and wchar_t, but not for
char32_t or char16_t.

There should also be simple cross-conversion functions along of
to_string/to_wstring to convert between string types.

-- To be more explicit:

Number conversion:
sto* have overloads for converting string and wstring to numbers.
to_string / to_wstring: converts numbers to string or wstring.

Streams:
stringstream / wstringstream, filebuf / wfilebuf, (io)fstream / w(io)fstream
The above are typedefs, but typedefs for char*_t would be helpful.

fstream::open finally has an std::string taking overload, but what if we
have a filename in a wstring?

Regex:
There are typedefs for basic_regex<char>, basic_regex<wchar_t>.

What do you think?

--
Thomas

[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: wasti.redl@gmx.net
Date: Tue, 14 Apr 2009 15:09:06 CST
Raw View
On Apr 4, 5:50 pm, "Thomas J. Gritzan" <phygon_antis...@gmx.de> wrote:
> We will have Unicode (utf8, utf16 and utf32) character types, strings
> and string literals in the next standard. Nice.
>
> I just skimmed through the N2857 working paper and found that we can
> hardly do anything with this Unicode strings. Many classes that work on
> strings are specified/typedef'd for char and wchar_t, but not for
> char32_t or char16_t.

Just because they're not typedefed doesn't mean you can't use them.
basic_string, at least, should most definitely work with those types.

>
> There should also be simple cross-conversion functions along of
> to_string/to_wstring to convert between string types.
>

Yes. But they're not very hard to write using the codecvt facets for
those new types, which are there.

More universal and consistent support for the new char types would be
nice anyway.

Sebastian


--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]