[Expat-discuss] Expat on 64 bit Linux

Karl Waclawek karl at waclawek.net
Fri Feb 5 14:16:23 CET 2010


On 04/02/2010 9:39 PM, Gabriel Becedillas wrote:
> Hi,
> I'm trying to use expat (the last version) on a 64 bit Linux (Intel).
> Both XML_UNICODE_WCHAR_T and XML_UNICODE are defined, and
> sizeof(wchar_t) == sizeof(XML_Char) == 4 bytes
> I understand that when my callbacks get called, each XML_Char should
> hold one character (at least that is the way it is working on a 32 bit
> Windows).
> Instead of that, what I'm getting is 2 characters in each XML_Char
> element. Like if it was treating a 4 byte XML_Char array as a 2 byte
> XML_Char array.
> Can anyone help me with this ?
> Thanks in advance.

Expat reports back to the application in either UTF-8 or UTF-16 encoding.
The options above generate UTF-16 output by Expat:
- XML_UNICODE: defines XML_LChar as char and XML_Char as unsigned short,
  which means that even if the application itself works with 8bit strings,
  it can still generate UTF-16 encoded XML output
- XML_UNICODE_WCHAR_T: defines XML_LChar and XML_Char as wchar_t

The second one requires wchar_t to be 16bit wide, so that UTF-16 can be
generated. Expat does not support UTF-32 output.

You should check the -fshort-wchar option for compiling.

Karl



More information about the Expat-discuss mailing list