Boost logo

Boost :

Subject: Re: [boost] Unicode and codecvt facets
From: Bo Persson (bop_at_[hidden])
Date: 2010-07-05 13:48:32

Mathias Gaunard wrote:
> On 05/07/10 17:27, Artyom wrote:
>>> As some may know, I am working on a Unicode library that I plan
>>> to submit to Boost fairly soon.
>> Take a look on Boost.Locale proposal.
> I know of it, yes.
> But my library purposely *doesn't* use the standard C++ locale
> subsystem because it's slow, broken, and inflexible.
> Nevertheless I want to provide the ability to bridge my library with
> that system.
>>> The codecs in that library are based around iterators and
>>> ranges, but since there was some demand for support
>>> for codecvt facets I am working on adapting those into that form
>>> as well. Unfortunately, it seems it is only possible to subclass
>>> std::codecvt<char, char, mbstate_t> and
>>> std::codecvt<wchar_t, char, mbstate_t>.
>> Yes, these are actually the only specialized classes.
> I was hoping I could specialize some more myself.

You can, but you should specialize on the third parameter, if you want
to treat chars differently than default.

A codecvt<char, char, my_state_t> could easily do any kind of
conversions you need.

You then only need to supply a non-default char_traits template
parameter to basic_fstream, with my_state_t as its state_type, and
imbue the file with a locale containing your specialized codecvt.

Who said it should be easy? :-)

Bo Persson

Boost list run by bdawes at, gregod at, cpdaniel at, john at