I implement serialization using Boost C ++ libraries in a program created for Windows (using Visual Studio 2008) and Mac (using GCC). The program uses wide lines ( std::wstring ) in about 30 classes. Depending on the platform, when I save the file (using boost::archive::text_woarchive ), the wide lines are presented differently in the output file.
Saved on Windows :
H*e*l*l*o* *W*o*r*l*d*!* ...
Saved on MacOSX :
H***e***l***l***o*** ***W***o***r***l***d***!*** ...
where * is the NULL character.
When I try to read a file created under Windows using the Mac build (and vice versa), my program crashes.
In my opinion, Windows initially uses 2 bytes per wide character, while MacOSX (and I assume that Unix in general) uses 4 bytes.
I have utf8_codecvt_facet.cpp across possible solutions such as utf8_codecvt_facet.cpp , UTF8-CPP , ICU and Dinkumware , but I still need to see an example that will work with what I already have (for example, I would prefer not to rewrite five months of serialization work in this moment ):
std::wofstream ofs( "myOutputFile" ); boost::archive::text_woarchive oa( ... );
myMainClass contains wide strings and boost smart pointers to other classes, which in turn receive serialization.
Tymek source share