Fwd: Lexical cast between narrow and wide strings
I hope this is the right place to post my question. I expected to be able to convert between narrow and wide strings using boost lexical cast but it fails to compile. I suppose that conversion is not supplied or supported. It would be really useful to me if it was. I am developing on win32 for wince and on wince there seeem to be many places where wide strings are required, especially when using the win32 API. Is there any chance this could be added to boost? I checked using boost 1.55.0 -- Regards, Andrew Marlow http://www.andrewpetermarlow.co.uk
Andrew Marlow wrote:
I hope this is the right place to post my question. I expected to be able to convert between narrow and wide strings using boost lexical cast but it fails to compile. I suppose that conversion is not supplied or supported. It would be really useful to me if it was. I am developing on win32 for wince and on wince there seeem to be many places where wide strings are required, especially when using the win32 API. Is there any chance this could be added to boost? I checked using boost 1.55.0
Have you checked Boost.Locale? E.g. http://www.boost.org/doc/libs/1_55_0/libs/locale/doc/html/charset_handling.h... Regards, Adam
This is great, exactly what I was looking for. Thanks! There is just one
snag. I see it is version 1.55.0 but not in 1.42.0. I use 1.55 privately
but the corporate environment uses 1.42. Do you know what version of boost
the locale stuff was introduced at? It doesn't seem to be in 1.42 in the
same way. I see references to utf conversions in spirit but it is done
differently.
On Jun 5, 2014 12:16 AM, "Adam Wulkiewicz"
Andrew Marlow wrote:
I hope this is the right place to post my question. I expected to be able to convert between narrow and wide strings using boost lexical cast but it fails to compile. I suppose that conversion is not supplied or supported. It would be really useful to me if it was. I am developing on win32 for wince and on wince there seeem to be many places where wide strings are required, especially when using the win32 API. Is there any chance this could be added to boost? I checked using boost 1.55.0
Have you checked Boost.Locale? E.g. http://www.boost.org/doc/libs/1_55_0/libs/locale/doc/html/ charset_handling.html
Regards, Adam _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Thu, Jun 5, 2014 at 2:50 AM, Andrew Marlow
Do you know what version of boost the locale stuff was introduced at? It doesn't seem to be in 1.42 in the same way.
This list: http://www.boost.org/doc/libs/ includes for each library the Boost release in which it was first introduced. According to that, Locale was introduced in 1.48.
Andrew Marlow wrote:
I hope this is the right place to post my question. I expected to be able to convert between narrow and wide strings using boost lexical cast but it fails to compile.
<snip>
Have you checked Boost.Locale? E.g.
http://www.boost.org/doc/libs/1_55_0/libs/locale/doc/html/charset_handling.h... 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.
On 7/06/2014 19:13, quoth gast128:
http://www.boost.org/doc/libs/1_55_0/libs/locale/doc/html/charset_handling.h...
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
Gavin Lambert
std::wstring wide_string = to_utf
(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.)
If the end result is Ansi and ucs-2 then it is ok (besides the misleading name). Added some random text here to circumvent the 'There's much more quoted text in your article than new. Prune quoted stuff.' message in gmane editor
participants (5)
-
Adam Wulkiewicz
-
Andrew Marlow
-
gast128
-
Gavin Lambert
-
Nat Goodspeed