Daily C++11: More Unicode support

In yesterday’s episode we talked about the new Unicode support for string literals; the standard library has also been extended to support the new encodings:

  • std::string defined as std::basic_string<char>
  • std::wstring defined as std::basic_string<wchar_t>
  • std::u16string defined as std::basic_string<char16_t>
  • std::u32string defined as std::basic_string<char32_t>

New codecs are defined for translation between these types. The codecvt set was extended with quite a few more codecs, that allow translation between all the supported encodings. For a full reference, see the CPP reference site.

Also, new conversion classes have been added. wstring_convert and wbuffer_convert can be used in conjunction with the new codecs to convert a string or a buffer.

Example code, from the CPP reference site (as I am currently unable to run it with my present setup):


Daily C++11: More Unicode support — 2 Comments

  1. Hmm, what I meant to type:

    Btw: Second code sample has html in it. [b] or [/b] is appearing in the code; you don’t need’em with [pre class=”brush:cpp”]