|
Boost : |
Subject: Re: [boost] Review Request: Boost.Locale
From: Artyom (artyomtnk_at_[hidden])
Date: 2010-05-24 02:10:42
> One thing in particular that I was interested in is(are)
> codecvt
> facets.Â
> I didn't any thing on this. Why is
> that?
Take a look on http://www.cplusplus.com/reference/std/locale/codecvt/
They allow you to imbue special charset to fstream and automatically
translate wide characters to normal encoding like UTF-8 or ISO-8859-8.
> Is this a separate
> subject or is that you believe they're not useful.Â
Theoretically they are very useful.
For example:
std::wofstream fs;
fs.imbue(std::locale("he_IL.UTF-8"));
fs.open("file.txt");
fs << L"ש×××"!
Would print UTF-8 output.
But...
- Many compilers/standard libraries do not implement locales at all.
(GCC under Windows and Solaris, STL Port library)
- Support of locales and encoding is strictly limited to OS
configuration. So on some host the above example would work on other
it would throw invalid locale error.
- Some compilers/OSes do not support UTF-8 encodings (MSVC) so
you can't create UTF-8 locale at all.
- Locales name are platform depended. For example under Windows
you need Hebrew_Israel.1255 locale and under Linux he_IL.ISO-8859-8
(and BTW 1255!=iso-8859-8)
So Boost.Locale reimplements standard codecvt facet to make this work
on any platform.
However there is still a limitation when working with 2 byte
characters (ie char16_t or wchar_t under windows) as Boost.Locale
would work correctly only with UCS-2
But this is actually C++ standard's limitation.
Best,
Artyom
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk