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

RE: UTF-8 vs UTF-16



Yes sir.  Exactly what I thought.  I actually have a call into the company to see if they are able to adjust that encoding information in the heading.  For the meanwhile, I am going to use the other technique.  And yes, I am lucky.  And thanks a lot for your help.


Robert Frohne
IT Manager
CLEAN
1316 South 7th Street
St. Louis, MO 63104
314.421.1234  Tel
RFrohne@xxxxxxxxxxxxxxxx
www.cleanuniform.com

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
[mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Scott Klement
Sent: Friday, February 28, 2014 12:18 PM
To: HTTPAPI and FTPAPI Projects
Subject: Re: UTF-8 vs UTF-16


Unfortunately, there is no way to override the encoding when using
http_url_get_xml or http_url_post_xml.  HTTPAPI will always feed the
data to Expat and expect Expat to figure it out.  So if it's provided an
incorrect encoding in the XML processing instructions, then it simply
won't work.

What you can do instead is this:

1) call http_tempfile() to get a unique IFS filename.
2) call http_url_get() to download the file.  Use the unique filename
from step 1.
3) call http_parse_xml_stmf() to parse the XML.   Here you can force it
to use the encoding you wish.
4) call the unlink() API from IBM, or the RMVLNK CL command to delete
the temporary file.

I'm amazed at this situation.  You'd think this web service wouldn't
work for anyone if they provide the wrong encoding in the XML document.
You're working in a situation where you're lucky you can interject your
own code into the processing.  Most environments don't have that luxury.

Good luck!


On 2/28/2014 6:49 AM, Robert Frohne wrote:
> Yes.  When I'm using the parse_xml_stmf, that works wonderfully.  I was now trying to handle it all within the http_url_get_xml.  There is no parm to pass for the encoding there.
> Danke,
> Bob
>
> On Feb 28, 2014, at 12:31 AM, "thomas.raddatz@xxxxxx" <thomas.raddatz@xxxxxx> wrote:
>
>> You may try to specify CCSID "1208" instead of "HTTP_XML_CALC" when
>> calling http_parse_xml_stmf():
>>
>> if (http_parse_xml_stmf( filename
>>                         : 1208
>>                         : *null
>>                         : %paddr(Incoming)
>>                         : *null ) < 0 );
>>
>> Thomas.
>>
>> ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx schrieb am 28.02.2014 00:00:11:
>>
>>> Von: RFrohne@xxxxxxxxxxxxxxxx
>>> An: ftpapi@xxxxxxxxxxxxxxxxxxxxxx,
>>> Datum: 28.02.2014 00:11
>>> Betreff: RE: UTF-8 vs UTF-16
>>> Gesendet von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>>>
>>> OK, another question:
>>> How can I get this to work?  It is apparently sending back xml as
>>> encoding="utf-16", but I'm getting the ubiquitous error of "XML
>>> parse failed at line 1, col 30: encoding specified in XML declaration is
>> inc."
>>> uri = 'https://api.zip2tax.com/TaxRate-USA.xml?' +
>>>       'username=sample&password=password&zip=90210';
>>> rc = http_url_get_xml(uri: *null: %paddr(getXml): *null);
>>> if (rc <> 1);
>>>    http_crash();
>>> endif;
>>>
>>> It seems to me the problem resides with how the data is sent back.
>>> It has a header saying "uff-16" when actually it is probably utf-8.
>>>
>>>
>>>
>>> Robert Frohne
>>> IT Manager
>>> CLEAN
>>> 1316 South 7th Street
>>> St. Louis, MO 63104
>>> 314.421.1234  Tel
>>> RFrohne@xxxxxxxxxxxxxxxx
>>> www.cleanuniform.com
>>>
>>>
> Robert Frohne
> IT Manager
> CLEAN
> 1316 South 7th Street
> St. Louis, MO 63104
> 314.421.1234  Tel
> RFrohne@xxxxxxxxxxxxxxxx
> www.cleanuniform.com
>
> -----Original Message-----
>>> From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>>> [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Scott Klement
>>> Sent: Wednesday, February 26, 2014 3:46 PM
>>> To: HTTPAPI and FTPAPI Projects
>>> Subject: Re: UTF-8 vs UTF-16
>>>
>>>
>>> Robert,
>>>
>>> HTTP_XML_CALC means that Expat will try to calculate the proper encoding
>>> to use based on the contents of the file.  If your file is in UTF-16
>>> format, and has a header of <?xml encoding="utf-16"?> at the top, then
>>> it should automatically work.
>>>
>>> If you want to force it to always use UTF-16 rather than detecting it,
>>> you can change 'HTTP_XML_CALC' to just use the number 1200 (which is the
>>> CCSID of UTF-16).
>>>
>>> Hope that helps!
>>>
>>>
>>>
>>> On 2/26/2014 2:00 PM, Robert Frohne wrote:
>>>> Can anyone help?
>>>>
>>>> When I'm using this bad-boy, how can I get it working with UTF-16
>> encoding?
>>>>   if (http_parse_xml_stmf( filename
>>>>                          : HTTP_XML_CALC
>>>>                          : *null
>>>>                          : %paddr(Incoming)
>>>>                          : *null ) < 0 );
>>>>
>>>>
>>>>
>>>>
>>>> Robert Frohne
>>>> IT Manager
>>>> CLEAN
>>>> 1316 South 7th Street
>>>> St. Louis, MO 63104
>>>> 314.421.1234  Tel
>>>> RFrohne@xxxxxxxxxxxxxxxx
>>>> www.cleanuniform.com
>>>>
>>>>
>> -----------------------------------------------------------------------
>>>> 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
>>> -----------------------------------------------------------------------
>>
>> --
>> IMPORTANT NOTICE:
>> This email is confidential, may be legally privileged, and is for the
>> intended recipient only. Access, disclosure, copying, distribution, or
>> reliance on any of it by anyone else is prohibited and may be a criminal
>> offence. Please delete if obtained in error and email confirmation to the sender.-----------------------------------------------------------------------
>> 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
-----------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------