× 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.




One more wrinkle to this... to get the length right on the otuput field, you'll need to start by expanding it to it's full size, then shrinking it back to only the size you're using.

So you'd do this on recent releases:

%len(W#TKN2) = %len(W#TKN2:*MAX);

len = base64_decode( %addr(W#TKN:*DATA)
: %len(%trimr(W#TKN))
: %addr(W#TKN2:*DATA)
: %len(W#TKN2:*MAX) );

%len(W#TKN2) = len;

Or, on older releases you'd do this:

%len(W#TKN2) = %size(W#TKN2) - 2;

len = base64_decode( %addr(W#TKN) + 2
: %len(%trimr(W#TKN))
: %addr(W#TKN2) + 2
: %size(W#TKN2) - 2 );

%len(W#TKN2) = len;

I don't know whether the %trimr() on the 2nd line is really needed, that depends on whether there are trailing blanks in W#TKN, but it shouldn't hurt anything.

Also keep in mind that base64 preserves the binary value of the string. So if your data was originally text data that was encoded in ASCII, UTF-8, or something like that, the output will still be in ASCII or UTF-8, or whatever. So if it is indeed text that you want to have in EBCDIC, you'll need to convert it after you decode it.

-SK





On 4/6/2015 2:59 PM, Scott Mildenberger wrote:
Since they are varying you can't just use %addr of the field, you need %addr(W#TKN : *data) so it points to the actual data part of the field bypassing the length portion at the beginning. If you are not at a new enough release use %addr(W#TKN : 2) instead. Do that for both fields in the call.

Scott Mildenberger


-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of RWesh@xxxxxxxxxxx
Sent: Monday, April 06, 2015 1:54 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: RE: Base64 Decode Help

Apologies

D rc S 10U 0
D W#TKN S 50a varying
D W#TKN2 S 50a varying


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.