Boost logo

Boost Users :

Subject: Re: [Boost-users] UTF-16
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2009-06-14 15:41:16


On Sun, Jun 14, 2009 at 1:08 PM, Zachary Turner <divisortheory_at_[hidden]>wrote:

> An application I currently work on is stricken with this. If (like
> us) you are just trying to provide basic internationalization across
> Windows and Linux and want it to "just work" and be simple, then I
> would suggest typedefing something like
>
> typedef std::wstring utf_string;
> typedef boost::filesystem::wpath utf_path;
> typedef wchar_t utf_char;
>
> etc on windows, and
>
> typedef std::string utf_string;
> typedef boost::filesystem::path utf_path;
> typedef char utf_char;
>
> on Linux. Then just use a simple UTF-8 <-> UTF-16 conversion if ever
> you need to persist / retrieve something, so that it's stored in a
> common format. We're getting many strange problems relating to
> locales when we try to use UTF-16 in wpaths on Linux, and if it's not
> too much effort it's going to be simpler to just have your program
> always store them in the native format that the OS is expecting.

Great advice Zach. I'll definitely do this. However, it would be nice to
have an already-made conversion routine for UTF8 to UTF16. I'm hoping that
most of the cases where I'm converting encodings will be when I'm going
through another library where it has already been handled, like wxWidgets or
boost.



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