Boost logo

Boost Users :

Subject: [Boost-users] (boost serialization) wstring portability issue
From: Arash Abghari (arash.abghari_at_[hidden])
Date: 2010-12-16 11:47:40


Hi,

I wonder if there is a way to have wstring portable between Windows and
Linux. To be more elaborative consider the following code:

wstring s(L"abcd");
std::ofstream
ofs("./my_archive",std::iostream::binary);
boost::archive::text_oarchive oa(ofs);
oa << s;

the file my_archive under Linux looks like this:

$ xxd my_archive
0000000: 3232 2073 6572 6961 6c69 7a61 7469 6f6e 22 serialization
0000010: 3a3a 6172 6368 6976 6520 3520 3420 6100 ::archive 5 4 a.
0000020: 0000 6200 0000 6300 0000 6400 0000 ..b...c...d...

while under Windows it looks like:

$ xxd my_archive
0000000: 3232 2073 6572 6961 6c69 7a61 7469 6f6e 22 serialization
0000010: 3a3a 6172 6368 6976 6520 3520 3420 6100 ::archive 5 4 a.
0000020: 6200 6300 6400 b.c.d.

as expected it reserved 4 bytes for each character under Linux while 2
bytes under Windows. Thus the archive file created under Linux is not
loadable under Windows and vice versa.

So my question is if there is a workaround or solution to this problem?

By the way I am using boost 1.40 , gcc 4.3.4 and VC 9.0.

Thanks,

Arash


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