[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Ftpapi] Problem with utf-8 data received using new http_string() procedure and YAJL.
- From: Scott Klement <sk@xxxxxxxxxxxxxxxx>
- To: FTPAPI/HTTPAPI mailing list <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
- Subject: Re: [Ftpapi] Problem with utf-8 data received using new http_string() procedure and YAJL.
- Date: Fri, 31 Mar 2017 14:09:28 -0500
Richard,
It's not clear to me what you are looking for. Do you want HTTPAPI to
assume the remote data is UTF-8 (by default it assumes ISO-8859-1)...
If so, you can do:
http_setOption('network-ccsid': '1208');
In this case, your RPG variable will get (by default) it's data in the
EBCDIC CCSID of your job, but it will be translated from UTF-8 rather
than ASCII. That should solve the issue for the particular characters
in your examples.
But, there are hundreds of thousands of characters that simply don't
exist in EBCDIC. What if you wanted the data to be returned to your
program un-translated, so that it is still in the original UTF-8? In
that case you could do this:
http_setOption('network-ccsid': '1208');
http_setOption('local-ccsid': '1208');
In this case, since the two CCSIDs are the same, it will not translate
the data at all.
The "old" way to do this is with http_setCCSIDs() (which will also still
work). For example, the older way to set the network CCSID is:
http_SetCCSIDs(1208: 0);
or to set both network/local so that there's no translation:
http_setCCSIDs(1208: 1208);
So that does the same thing as the above... I just think
http_setOption() is easier to read.
-SK
On 3/31/2017 11:11 AM, la Croix, Richard wrote:
Hello all,
I am having a problem with utf-8 data received using the new
http_string procedure.
When I use http_stmf() I can first set the ccsid for the output file
to 1208 (using http_setOption('file-ccsid': '1208')), as JSON data
should always be utf-8 (ccsid 1208).
I can then process the file with yajl_stmf_load_tree() and the utf-8
strings are converted correctly.
I would like to skip the detour via the ifs and directly process the
string as received using the http_string() procedure. However when I
pass the output from http_string() to yajl_buf_load_tree() the JSON
fields containing utf-8 data come out wrong (e.g. ‘Randonnée’ vs.
‘Randonnée’).
As far as I can see, there is no equivalent to setting
http_setOption('file-ccsid': '1208') for directly receiving utf-8 data
into a variable.
Am I missing something? Any ideas?
Best regards,
Richard
*Richard la Croix *
Software Developer
IT & Telecommunication
Hapimag AG
Neuhofstrasse 8
6340 Baar
Schweiz
Phone +41 (41) 7 67 81 53
Fax +41 (41) 7 67 89 10
_richard.lacroix@xxxxxxxxxxx
_*facebook * <http://www.facebook.com/hapimag>
*_Geschaeftssitz:
_Hapimag AG
*Neuhofstrasse 8
6340 Baar
Schweiz
Eingetragen: Handelsregister des Kantons Zug
Firmennummer/UID: CHE-101.391.790
MWST.-Nr.: CHE-101.391.790 MWST
COB: Dr. Giatgen Peder Fontana
CEO: Hassan Kadbi
FinanceOfficeCH@xxxxxxxxxxx <mailto:FinanceOfficeCH@xxxxxxxxxxx>
Member of the Hapimag Group <http://www.hapimag.com/hapimaggroup>
www.hapimag.com <http://www.hapimag.com>
--
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi