× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




This worked perfectly. Thanks!

________________________________
From: WEB400 <web400-bounces@xxxxxxxxxxxx> on behalf of Slanina, John <jslanina@xxxxxxxxxx>
Sent: Monday, December 17, 2018 4:08 PM
To: Web Enabling the IBM i (AS/400 and iSeries)
Subject: Re: [WEB400] UTF-8 conversion in a REST program

So what you is this ?

Dcl-s varInput varChar(65535) ;
Dcl-s varinputUTF8 like(varName) ccsid(*utf8) ;

if ContentType = 'application/json' or ContentType = 'application/vnd.api+json';
QtmhRdStin(varInputUTF8: RdiLen : RdiRecLen : APIErr);
varInput = varInputUTF8;
else;
QtmhRdStin(varInput: RdiLen : RdiRecLen : APIErr);
endif;

Thanks
John Slanina

On 12/17/18, 2:14 PM, "WEB400 on behalf of Justin Taylor" <web400-bounces@xxxxxxxxxxxx on behalf of JUSTIN@xxxxxxxxxxxxx> wrote:

RPG has built-in CCSID conversion, starting (IIRC) at 7.3.



-----Original Message-----
From: Slanina, John [mailto:jslanina@xxxxxxxxxx]
Sent: Monday, December 17, 2018 1:09 PM
To: Web Enabling the IBM i (AS/400 and iSeries) <web400@xxxxxxxxxxxx>
Subject: Re: [WEB400] UTF-8 conversion in a REST program

Here is my code to so it. If you need a quick fix. There is other ways in YAJL to do it in one program

Thanks
John Slanian



dcl-ds fromCCSID likeds(QtqCode_t) Inz(*LIKEDS);
dcl-ds toCCSID likeds(QtqCode_t) Inz(*LIKEDS);
dcl-ds hConv likeds(iconv_t) Inz(*LIKEDS);

dcl-ds iconv_t Qualified template;
rtn_value int(10);
cd int(10) dim(12) inz(0);
end-ds;

dcl-pr ibmIConvOpen LikeDS(iconv_t) ExtProc('QtqIconvOpen');
*n likeds(QtqCode_t);
*n likeds(QtqCode_t);
end-pr;

dcl-pr ibmIConv int(10) ExtProc('iconv');
*n LikeDS(iconv_t) value;
*n pointer;
*n int(10) Const;
*n pointer;
*n Int(10) Const;
end-pr;

dcl-pr ibmIconvClose int(10) extproc('iconv_close');
*n LikeDS(iconv_t);
end-pr;

monitor;
envrec = *blanks;
EnvName = 'CONTENT_TYPE';
QtmhGetEnv(EnvRec : %size(EnvRec) : RecLen : EnvName : %Len(%Trim(EnvName)) : APIErr);
ContentType = %xlate(uppercase:lowercase:%trim(%Subst(EnvRec : 1 : RecLen))); on-error; endmon;

// Read Body

monitor;
QtmhRdStin(RdiRec : RdiLen : RdiRecLen : APIErr); on-error; endmon;

if ContentType = 'application/json' or ContentType = 'application/vnd.api+json';
monitor;
RdiLenOut = RdiRecLen;
RdiRec_P = %addr(RdiRec);
RdiRecOut_P = %addr(RdiRecOut);

rc = ibmIConv(hConv : RdiRec_P : RdiRecLen : RdiRecOut_P : RdiLenOut);

RdiRec = %trim(RdiRecOut);
RdiRecLen = %len(%trim(RdiRec));

on-error;
endmon;
endif;

On 12/17/18, 2:00 PM, "WEB400 on behalf of Rich Dotson" <web400-bounces@xxxxxxxxxxxx on behalf of rich_dotson@xxxxxxxxxxx> wrote:


I wasn't using YAJL in the REST program because all it was doing was receiving the JSON payload and writing it to the IFS as a stream file and returning an HTTP "accepted" message back to the calling process. I am using YAJL in the program that reads the JSON files in the IFS and processes the data. It seemed simpler to just read the payload via QtmhRdStin. I'll look into incorporating YAJL instead.


________________________________
From: WEB400 <web400-bounces@xxxxxxxxxxxx> on behalf of Jon Paris <jon.paris@xxxxxxxxxxxxxx>
Sent: Monday, December 17, 2018 12:59 PM
To: Web400@Midrange. Web400
Subject: Re: [WEB400] UTF-8 conversion in a REST program

Why bother with EBCDIC ? JSON is supposed to be UTF-8 and YAJL - for one - will handle that just fine.


Jon Paris

www.partner400.com<http://www.partner400.com>
www.SystemiDeveloper.com<http://www.SystemiDeveloper.com<http://www.SystemiDeveloper.com<http://www.SystemiDeveloper.com>>

> On Dec 16, 2018, at 7:38 PM, Rich Dotson <rich_dotson@xxxxxxxxxxx> wrote:
>
>
> I have a RPGLE REST program that receives orders in a JSON payload from our Salesforce application. It was working great until last week when they changed the content-type in the header from "text/json" to "application/json". The payload is now garbled and I believe that it is coming in as UTF-8 and is not being translated by the web server they way it was when the content-type was "text/json".
>
> I've tried a few different coding techniques to convert the data received but haven't had any success. Can someone point me to example program that converts the data read in from StdIn from UTF-8 to EBCDIC?
>
> Thanks,
> Rich
> --
> This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
> To post a message email: WEB400@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: https://lists.midrange.com/mailman/listinfo/web400
> or email: WEB400-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at https://archive.midrange.com/web400.
>

--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.

--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.



--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.



--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.