Alright, so I am writing a server client application that has to work cross platform, between Windows and linux. Now the deal is that the server and client can run on both platforms which makes managing the conversions a little more difficult.
To start off explaining this problem I am going to post a bit of output from some code I wrote to give me the sizes of a few various type on both linux and Windows.
Size of types in linux (gcc 2.3.3/gentoo 1.4rc1):
-------------------------------------------------
Sizeof: bool 1
Sizeof: int 4
Sizeof: unsigned int 4
Sizeof: long 4
Sizeof: double 8
Sizeof: float 4
Sizeof: unsigned char 1
Sizeof: char 1
Sizeof: wchar_t 4
Size of type in windows (MSVC++.net 2003), Windows XPsp2:
---------------------------------------------------------
Sizeof: bool 1
Sizeof: int 4
Sizeof: unsigned int 4
Sizeof: long 4
Sizeof: double 8
Sizeof: float 4
Sizeof: unsigned char 1
Sizeof: char 1
Sizeof: wchar_t 2
As you can see they are all pretty much the same, except wchar_t. On linux it is 4 bytes, I presume that it is using USC4 (if I recall correctly, I have this written down somewhere), however a quick googling has not really revealed to me what character encoding windows happens to be using... USC2? UTF16? And to make matter worse I have to figure out how to transfer all this data and preserve to data.
The most obvious, and probably best solution considering transfers will occure over a network is just to use the local setting and encode all the streams in UTF8 format before transferring since this tends to take less bandwidth when using latin based languages an characters and should provide an easy means for converting between most UCS and UTF formats.
Anyway, if anyone can tell me what format windows is using that is causing wchar_t to be represented by a 2 byte array I would greatly appreciate it, and maybe some info on converting between the two operating system.
Thanks....