Page 1 of 1

Issue with EBCIDIC to ASCII conversion

Posted: Tue Jan 03, 2023 11:19 pm
by jarhead0311
I have a program written to return a JSON, but in Postman it appears as garbage. I'm assuming I'm missing something in the httpd.conf file. I looked at the httpd.conf file and it had a 'CgiConvMode %%MIXED/MIXED%%' but nothing for the DefaultFsCCSID and DefaultNetCCSID.

When I look at the apachedft job I see these attributes:

CODED CHARACTER SET IDENTIFIER . . . . . . . . . : 65535
DEFAULT CODED CHARACTER SET IDENTIFIER . . . . . : 37

I've searched and found this thread where Scott mentioned having an issue converting to EBCDIC to ASCII if the header has "application/" in the type, which mine does, being a JSON file. I've tried adding ccsid(*utf8) to the data variable and sending that in the QtmhWrStout command, but I'm still getting garbage.
Personally, the setup I use is like this:

DefaultFsCCSID 37
DefaultNetCCSID 1208
CgiConvMode %%MIXED/MIXED%%

This tells Apache that my local system is CCSID 37 for EBCDIC (you might want 278 for Sweden, I don't remember) and that the network should be CCSID 1208 (UTF-8). This will cause Apache to translate the data from UTF-8 to EBCDIC when receiving, or from EBCDIC to UTF-8 when sending.

If you leave off the DefaultNetCCSID, it will use CCSID 819, I believe -- and that's not Unicode, it's ASCII.

The other thing I've noticed is that if you use 'text/xml' it will translate it, but 'application/xml' will not. It seems to differentiate between text documents vs. non-text -- and since XML is text, but has 'application' it causes problems. Same for 'application/json'. Therefore, you may need to read into a CCSID(*UTF8) field in your RPG program, and convert it yourself. Depending on the circumstances.
I tried adding the the DefaultFsCCSID and DefaultNetCCSID as you mentioned above as well with no improvement. Any suggestions? Thanks in advance!

Re: Issue with EBCIDIC to ASCII conversion

Posted: Thu Jan 05, 2023 8:38 am
by Scott Klement
As it says in the message you quoted, the Apache server doesn't typically perform conversion on application/json (or any non-text media types).

Re: Issue with EBCIDIC to ASCII conversion

Posted: Thu Jan 05, 2023 4:23 pm
by jarhead0311
I figured that out. When I changed it to text/json it worked. Thanks, Scott.