unichar can be more than 2 bytes? I thought it was always 2 bytes.
WolfPack
Postaholic
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
unichar can be more than 2 bytes? I thought it was always 2 bytes.
The size of wchar_t is operating system dependent. On MS-Windows wchar_t is defined as unsigned short. *nix computers it is unsigned long. And the UNICODE standards say that they intend to have 64-bit wchr_t.
That becomes a very big problem when attempting to port a UNICODE file between operating systems.
smality: No sure if this will help or not.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
I don't use c++ streams for UNICODE for the reasons you describe -- its a lot easier to use C's FILE, fopen() in binary mode, fread() and fwrite(). You don't have to worry about conversion that way. That works providing you don't want to transport the file from one operating system to another and you don't want to use another editor such as Notepad.exe to read it.
If you still want to use wfstreams, you can use mbstowcs() to convert from char* to wchar_t*, or wcstombs() to convert the other direction.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
you will probably have to write your own conversion functions that compress those 32-bit characters into 16 or 8 bit characters. But that may not work if the data requires all (or most) 32 bits to store each character, such as needed by many of the eastern languages (Chines, Japanese, etc).
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343