
(Was: Re: [Boost-users] Filesystem, serialization, character encoding and
portable software)
On 14 August 2008 00:44, Robert Ramey
Daniel Krügler wrote:
Robert Ramey wrote:
the wide character xml archives use UTF8.
the narrow character xml archives use the currently set locale.
Robert Ramey
Sorry for asking offhand:
What is the reasoning behind this different behaviour?
I assumed that most programs built with narrow characters used the locale concept to deal with this.
Wide character systems lend themselves to UTF coding so I used that for wide char archives. In order to do this, I used Ron Garcia's UTF code conversion facet for streams.
It would be quite easy to generate UTF coding for narrow character archives. Just do the following:
a) Build the UTF code conversion facet for narrow character input (its templated on character type).
b) When the stream is opened, attach this facet to the stream.
Note the the output char format is not really a property of the serialization library, but rather an artifact of the way it has been used. That is, the serialization library depends on the standard stream library for this property.
I understand that to get a UTF-8 XML file, I need to use a wide-character stream, but I can't seem to understand how I can compress a serialized UTF-8 xml archive... it seems I can either do: namespace bio = boost::iostreams; namespace fs = boost::filesystem; fs::wofstream ofs(path,ios::binary); bio::filtering_streambio::output,wchar_t out; out.push(bio::gzip_compressor()); // PROBLEM: gzip_compressor only accepts char out.push(ofs); boost::archive::xml_woarchive oa(out); --- OR --- fs::ofstream ofs(path,ios::binary); bio::filtering_streambio::output out; out.push(bio::gzip_compressor()); out.push(ofs); boost::archive::xml_woarchive oa(out); // PROBLEM: only accepts wostream I've googled but haven't found anything relevant... either people use an ifstream with gzip_compressor, or they don't use gzip_compressor at all. thanks, Paul