Page 1 of 1
YAJL_GET_STRING UTF8
Posted: Thu Sep 12, 2024 11:37 pm
by captainfruitbat
I have a legacy RPGLE program that uses YAJL to parse JSON data from the IFS into a character column in an IBM i database table. This has been working well for years when the incoming data was basic ASCII and the table column was EBCDIC. We now need to handle a much broader set of characters. The JSON data in the IFS is UTF8, and I have a test version of the database table with the relevant field defined with the UTF8 CCSID (1208). I was hoping that using YAJL_GET_STRING to retrieve the IFS data into the database field would keep it all in UTF8, but it seems to return EBCDIC data - I'm guessing it is using the job CCSID (37 in our case) to do implicit conversion. Any suggestions for how I can get the UTF8 data into my database table?
If it helps, the IBM i is on 7.2, QCCSID 65535 (Yes, I know..... not under my control), QLANGID 37.
Re: YAJL_GET_STRING UTF8
Posted: Fri Sep 13, 2024 12:15 am
by Scott Klement
Please use YAJL_GET_STRING_UTF16().
Even if the variable in your RPG program is coded with ccsid(*utf8) or ccsid(1208), this should work properly. (RPG will automatically translate it to UTF-8 for you.)
But, I would recommend that you use UTF-16 in your database. IBM has always recommended that database fields use UTF-16 rather that UTf-8. It performs much better, and the support is far more complete.
UTF-8 is great for network transfers because it is smaller. But UTF-16 is the one you want to use inside your application if at all possible.
Re: YAJL_GET_STRING UTF8
Posted: Fri Sep 13, 2024 2:59 am
by captainfruitbat
Thanks Scott - will give that a try. Your comments about using UTF-16 in the database are noted, and I will make that change.
Re: YAJL_GET_STRING UTF8
Posted: Sun Sep 15, 2024 10:41 pm
by captainfruitbat
It turns out the version of YAJL on this IBM i does not have YAJL_GET_STRING_UTF16. Must be quite old. I will get it updated to the latest version. When I install the new YAJL version, do I need to identify and recompile any RPGLE programs that use it? I will use the same library name for YAJL.
Re: YAJL_GET_STRING UTF8
Posted: Wed Sep 18, 2024 12:45 am
by Scott Klement
No, it's backward compatible... everything will work without any recompiles
Re: YAJL_GET_STRING UTF8
Posted: Wed Sep 18, 2024 4:14 am
by captainfruitbat
Fantastic - thanks Scott