[Expat-discuss] Expat and 4-byte wchar_t

Karl Waclawek karl at waclawek.net
Wed Jan 15 15:22:16 EST 2003


----- Original Message ----- 
From: "Marc White" <whitemar at us.ibm.com>
To: <expat-discuss at libexpat.org>
Sent: Wednesday, January 15, 2003 3:04 PM
Subject: [Expat-discuss] Expat and 4-byte wchar_t


> Hi all.
> 
> My team is currently using expat version 1.2. In the header file 
> xmlparse.h, there is a comment that says XML_UNICODE_WCHAR_T will only 
> work if sizeof(wchar_t) == 2. Does this restriction still apply to the 
> latest version (1.95.5)? I was unable to find the same comment indicating 
> that it would not work, although our tests with this version with a 4-byte 
> wchar_t, have not been successful so far.

Even if it worked, this would produce incorrect output, since
the code unit size for UTF-16 is 2 bytes,and Expat only produces
UTF-8 or UTF-16 output. 

However, if your compiler supports changing the size of
wchar_t (newer versions of gcc do) then you should be OK.
If not, do not define XML_UNICODE_WCHAR_T, but define XML_UNICODE.
Expat will then produce output as unsigned short * (except for error
and version strings, which will be char *).

Karl



More information about the Expat-discuss mailing list