Boost logo

Boost Users :

Subject: Re: [Boost-users] Fwd: Lexical cast between narrow and wide strings
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2014-06-11 00:45:20


On 7/06/2014 19:13, quoth gast128:
> http://www.boost.org/doc/libs/1_55_0/libs/locale/doc/html/charset_handling.html
>
> This seems from / to utf stuff. But there seems no ansi (i.e. 1 byte fixed
> length with the ascii set) to ucs-16 (fixed 2 byte) conversion. Both
> character encodings cannot cover all code points, but are very common on
> windows platforms due to historical reasons.

std::wstring wide_string = to_utf<wchar_t>(latin1_string,"Latin1");

is a conversion to UTF-16 from "Latin1", which is the most common ANSI
codepage (and there's discussion on there for using other codepages).
What more were you after?

(Yes, I know that UCS-2 and UTF-16 are not the same, but the differences
are usually insignificant in practice. In particular modern Windows
systems all support UTF-16.)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net