[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EXPAT service program which comes with HTTPAPI



Hi Scott,
I suspected this after I'd sent this mail, so I did a quick few tests
and indeed it is UTF16, and my problems were compounded by the fact I
was using standard header files, which assume UTF8, so the XML_Char
type was wrong, so when I did a "sizeof" on the type, it came back as
"1", when it blatantly was not...

Thank you for the iconv tip, for some reason I had it in my head that
the UTF16 CCSID was added very recently, and would not be on V5R1, but
I think from IBM docs, that is available that far back after all.

Thanks for the help, and for porting Expat in the first place, will
make my life much easier!

Cheers

Garry

On Mon, May 11, 2009 at 7:03 PM, Scott Klement <sk@xxxxxxxxxxxxxxxx> wrote:
> Hi Garry,
>
> The data that's passed to your callbacks will be in UTF-16 format, not
> EBCDIC.  If you try to treat it as a zero-terminated string (as is
> standard in C) you'll have a bad time of it, since each character is two
> bytes long, and the first byte of most common characters is 0x00.  So
> you'll end up will an "empty string".
>
> To determine the size of the element names, attribute names & attribute
> values, you'll need to look for two consecutive bytes set to 0x00.
>
> In the character data handler, the size of the string should be passed
> as one of the args to your function, so you won't want to search for
> zeros in that case.
>
> Once you get the data, use iconv() to convert it from UTF-16 (IBM CCSID
> 1200) to EBCDIC...  then you'll have an ordinary string you can use for
> your own purposes.
>
>
> Garry Taylor wrote:
>> Hi All,
>> I'm attempting to use the EXPAT service program which is supplied with
>> HTTPAPI, and I'm linking it to my program like so:
>>
>> CRTPGM PGM(THEGMAN1/TESTEXPAT) MODULE(THEGMAN1/EXPATMAIN)
>> BNDSRVPGM(LIBHTTP/EXPAT)
>>
>> I got the Expat header files from the source distribution of Expat,
>> and compiled one of the example programs which is supplied. All of
>> this went without incident, until I run the PGM, when it processes the
>> XML without error, but on the start element handler, it does not print
>> out either name or any of the element attributes, although it does
>> print out the depth in the XML tree of each element and no parse error
>> is given.
>>
>> If I deliberately invalidate the XML, this is reported perfectly, so I
>> think the parser is working just fine, but the printing is not.
>>
>> I'm doing all this in C, and my XML file is untouched UTF8, so at what
>> point can this text be converted to EBCDIC to get printed, does this
>> sound like the problem?
>>
>> Any ideas what the problem is?
>>
>> Thanks
>>
>> Garry
>> -----------------------------------------------------------------------
>> This is the FTPAPI mailing list.  To unsubscribe, please go to:
>> http://www.scottklement.com/mailman/listinfo/ftpapi
>> -----------------------------------------------------------------------
>>
>
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list.  To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> -----------------------------------------------------------------------
>
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------