Boost logo

Boost Users :

Subject: Re: [Boost-users] encoding data when serializing
From: Robert Ramey (ramey_at_[hidden])
Date: 2012-03-09 11:55:06


Sean Farrow wrote:
> What does the facet need to do?
> Cheers
> Sean.
>

The facet transforms a stream of characters (wide or narrow) into another
stream of characters (wide or narrow) and vice-versa. Once built
it is threaded into the standard library stream via some standard library
calls. This is a general mechanism for tranforming stream i/o from
one representation to another.

For more information study the documentation for the standard library.

Also for an example, you can study the serialization library source
code which uses this functionality to transform wide char i/o to
utf-8 i/o. The library also includes a codecvt facet for doing this
which might be used as an example.

Basically, the designers of the C++ standard i/o forsaw exactly
this situation and made provision for it. It's all in there, you just
have to use it.

Note that this is note an issue having anything to do with the
serialization library. It only seems that way because the serialization
library uses stream i/o and hence will inherit any features of
the stream which it uses.

If one had nothing else to do, he could make a boost library
to help make and compose (stack) codecvt facets. Much (or all)
of this functionality might overlap with the boost io streams
library. Or it might not. I've only looked at the boost io streams
library enough to know that it doesn't use codecvt facets. I
asked at one time why this was so - but didn't get any response.

Robert Ramey


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