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

Re: expat encoding



Gerald,

FTP doesn't know ANYTHING about the contents of your file. It assigns 819 to everything (no matter what it really is) unless you explicitly tell it to assign something else.

Given that the XML file states that it's Cp1252, I would assume the data to be 1252, unless you translated it. To fix this, run:
CHGATR OBJ('/path/to/yourfile.xml') ATR(*CCSID) VALUE(1252)

Expat does not understand the file system's CCSIDs, however, and does not understand "Cp1252" as an encoding in any case. so to solve the problem in a program that calls Expat directly, you'll want to use the open() API to translate the file from 1252 to 1208 (1208 is UTF-8 which contains every character possible in 1252). Then, when you create your parser in Expat, specify that the data is UTF-8. This will cause Expat to ignore the encoding in the XML header, and it will treat the data you pass to it as UTF-8.

the XML code in HTTPAPI can take care of the character set processing for you. In HTTPAPI (assuming you ran the CHGATR command) it will automatically convert to UTF-8 under the covers, and let Expat know that the data is UTF-8. In that case, you can just do this:

rc = http_parse_xml_stmf( stmf: HTTP_STMF_CALC: %paddr(start): %paddr(end): %addr(userdata));

The HTTP_STMF_CALC tells HTTPAPI to calcualte the encoding from the CCSID you assigned to the *STMF object in the IFS (via the CHGATR command.)

-SK


On 12/5/2012 4:34 PM, Gerald Magnuson wrote:
1) wrong list...  I am trying to use code from LIBEXPAT, now I will try to find an example in LIBHTTP..

2) after if FTP'd my xml to the ifs, I saw the CCSID was 819 (option 8 on wrklnk)



-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------