I have done this quite a few times before, so I'm not sure why I'm struggling so much with this...
I'm getting a json document from a server that contains a base64 encoded string representing a packing slip... I'm able to copy the data from the webservice response file (JSON) on the IFS, and paste that into an online decoder. That works.
But when I try to do he same in my program, I'm getting an error:
" Unable to decode character at position 1. (Char=x'4A') "
Using the online decoder, indicating UTF8, it will decode. Using the same decoder, selecting autodetect, it decodes differently indicating windows 1252?
Just wondering if anyone can spot any glaring errors in my code. I've been looking at it all morning. UGH.
// definitions
dcl-s base64encoded varchar(1000000) ccsid(*utf8) inz;
dcl-s base64decoded char(1000000) inz;
dcl-s fd int(10);
dcl-s pdfFile varchar(128) inz;
dcl-s pdfData varchar(1000000) ccsid(*utf8) inz;
// Decode Packslip Data
base64Encoded = json.data.node.packingSlipPdfData;
len = base64_decode( %addr(base64Encoded:*data)
: %len(%trim(base64Encoded))
: %addr(base64Decoded)
: %size(base64Decoded)
);
pdfData = %subst(base64decoded:1:len);
pdfFile = fldr + '/packslips/' + inCom + '_' + inOrd + '.pdf';
flag = o_wronly + o_creat + o_ccsid + o_excl;
mode = s_irusr + s_iwusr + s_iroth + s_iwoth;
fd = open(pdfFile:flag:mode:1208:0); // PDF is UTF8
rc = write( fd
: %addr(pdfData:*data)
: %len(pdfData));
[Logo]<
https://www.totalbizfulfillment.com/> Greg Wilburn
Director of IT
301.895.3792 ext. 1231
301.895.3895 direct
gwilburn@xxxxxxxxxxxxxxxxxxxxxxx<mailto:gwilburn@xxxxxxxxxxxxxxxxxxxxxxx>
1 Corporate Dr
Grantsville, MD 21536
www.totalbizfulfillment.com<
http://www.totalbizfulfillment.com>
As an Amazon Associate we earn from qualifying purchases.