Re: Decode base64 to job CCSID?

Daniel Gross <[email protected]> Thu, 2 Apr 2026 14:48:57 +0200
Newsgroups gmane.comp.lang.as400.rpg
Message-ID <[email protected]>
Well - as I'm on holiday right now, I have to poke around a bit - try the following please:

  dcl-ds decoded qualified;
    blob sqltype(blob:1000);
    utf8 varchar(1000:4) ccsid(*utf8) pos(1);
  end-ds;

The rest should be the same. The varchar(...:4) is important as the BLOB var uses an UNS(10) length field (which is 4 bytes). 

Please try - if if doesn't work, can you send some more info? Version/release etc. so I can dig deeper. 

HTH
Daniel


> Am 02.04.2026 um 14:37 schrieb Justin Taylor <[email protected]>:
> 
> decoded.blob gave me a 42806 (Variable DECODED.BLOB not compatible or value
> too long.)
> 
> 
> Javier, I tried moving the variable into another identical variable as you
> suggested, but that gave the same results.
> 
> 
> 
> Ideally, I'd love a SQL solution.  I've got a iconv() example, but I really
> don't want to go there.
> 
> 
> Thanks
> 
> 
> 
>> On Wed, Apr 1, 2026 at 1:15 PM Daniel Gross <[email protected]> wrote:
>> 
>> Ah - yes - BASE64_DECODE returns a blob without CCSID (or better with
>> *HEX).
>> 
>> I solved this lately with a DS:
>> 
>>   dcl-ds decoded qualified;
>>     blob varchar(1000);
>>     utf8 varchar(1000) ccsid(*utf8) samepos(blob);
>>   end-ds;
>> 
>>   exec sql set :decoded.blob = QSYS2.BASE64_DECODE(:encoded);
>>   return decoded.utf8;
>> 
>> I think this works quite OK - you could of course do this also with some
>> pointer-arithmetic.
>> 
>> HTH
>> Daniel
>> 
>> 
> --
> This is the RPG programming on IBM i (RPG400-L) mailing list
> To post a message email: [email protected]
> To subscribe, unsubscribe, or change list options,
> visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: [email protected]
> Before posting, please take a moment to review the archives
> at https://archive.midrange.com/rpg400-l.
> 
> Please contact [email protected] for any subscription related questions.
> 
-- 
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact [email protected] for any subscription related questions.