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



I get the same result in the SQL tool on V7R5.
Looks like the function systools.base64decode is returning UTF8 data but does not tell SQL that the character field has a CCSID.
So, its returned without a CCSID. 65535.

When I pass the result through hex it returns the 1208 hex values for the string.
HEX( systools.base64decode(…) )

On V7R5, when using just “values BASE64_DECODE(..)”, I’m getting back a BLOB that is appears to be the value UTF8 data as well.

I can’t even pass the value through interpret() to cast it to 1208 because the length is variable.



The only way I can get this to work in RPG is to use CCSID(*HEX) for the receiver variable.

Dcl-s Var1 Varchar(4096) CCSID(1208);
Dcl-s Var2 Varchar(4096) CCSID(1208);
Dcl-s Var3 Varchar(4096) CCSID(*HEX);

Var2 = 'aHR0cHM6Ly93d3cuaWJtLmNvbS9kb2Nz+
L2VuL2kvNy41P3RvcGljPW92ZXJ2aWV3+
LWJhc2U2NGRlY29kZS1zY2FsYXItZnVu+
Y3Rpb24=';

Exec Sql set :var1 = systools.base64decode(:Var2);
// SQLSTATE = '57017'
// SQL0332 Character conversion between CCSID 65535 and CCSID 1208 not valid.



Var2 = 'aHR0cHM6Ly93d3cuaWJtLmNvbS9kb2Nz+
L2VuL2kvNy41P3RvcGljPW92ZXJ2aWV3+
LWJhc2U2NGRlY29kZS1zY2FsYXItZnVu+
Y3Rpb24=';

Exec Sql set :Var3 = systools.base64decode(:Var2);


Var2 = 'aHR0cHM6Ly93d3cuaWJtLmNvbS9kb2Nz+
L2VuL2kvNy41P3RvcGljPWZ1bmN0aW9u+
cy1iYXNlNjQtZGVjb2Rl';

Exec Sql set :var1 = base64_decode(:Var2);
//SQLSTATE 42806
//SQL0303 Variable VAR1 not compatible or value too long.

Var2 = 'aHR0cHM6Ly93d3cuaWJtLmNvbS9kb2Nz+
L2VuL2kvNy41P3RvcGljPWZ1bmN0aW9u+
cy1iYXNlNjQtZGVjb2Rl';

Exec Sql set :Var3 = BASE64_DECODE(:Var2);



--
Chris Hiebert
Senior Programmer/Analyst
Disclaimer: Any views or opinions presented are solely those of the author and do not necessarily represent those of the company.

From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Jack Woehr via RPG400-L
Sent: Tuesday, January 16, 2024 12:12 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Cc: Jack Woehr <jwoehr@xxxxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: Base64Decode



Weird, I base64 encode a string using base64 in PASE or Linux and then pass

it to systools.base64decode() and I get garbage back.

I wondered if the garbage was EBCDIC, but I tried converting it and no go.

Wonder what's happening here?



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.