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



Jerry,

Your first mistake, I think, was not checking for errors after the SQL statement.  If you had done it like this:

exec sql values QSys2.Base64_DeCode(:Base64String) Into :DecodedLabel;
if %subst(Sqlstt:1:2) <> '00';
   // error handling here
endif;

You would've seen right away that the statement was getting an error.  Then, you could've looked in the job log and you would've seen this message:

SQL0303 Variable DECODEDLABEL not compatible or value too long.

So DecodedLabel -- the return value from Base64_Decode -- is incompatible with the function.  If you look at the SQL manual, it says that it returns a variable length string that is defined as "for bit data" -- in other words, binary data.  But you have yours declared as CCSID(1208) -- in other words, UTF-8 text data rather that binary data.

So hopefully that explains why you could solve the problem by coding a VARBINARY value.

All of this makes a lot of sense when you think about the purpose of base64 -- which is to allow arbitrary binary data to be converted to a text data that can be translated across different character sets without changing its meaning -- and then decoded back to the exact same binary value you started with.

I understand that in this particular scenario, the input just happened to be UTF-8 text -- but remember that base64 serves a lot of other purposes than just encoding Zebra labels.  It's regularly used for things that aren't text at all (images, videos, sounds, documents of all sorts.)  So it is always binary data.

It is your job to know that the input happened to be UTF-8, and it is an extra step that you have to code if you want to convert it to EBCDIC .  (Though, I don't really understand why you'd want to.)

But that's why there's an extra step needed.


On 1/17/2024 1:33 PM, (WalzCraft) Jerry Forss wrote:

Sorry about the image.

I was just a screen shot of debut with the value of
^XA████^FX Spee-Dee Logo██^FO510,154^GFA,

Getting closer!

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of (WalzCraft) Jerry Forss
Sent: Wednesday, January 17, 2024 1:22 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: External RE: Base64Decode

I found an example of doing a bit differently but getting closer.



Add varibles

Dcl-S DecodedTextVarBinary sqltype(VARBINARY:4096);

Dcl-S DecodedLabel VARCHAR(4096) CCSID(1208);



And change code to do



// Decode the encoded text into an EBCDIC VarBinary field

Exec SQL Values QSYS2.BASE64_DECODE(:Base64String) Into :DecodedTextVarBinary;



// Translate binary data in EBCDIC to UTF-8

DecodedLabel = DecodedTextVarBinary;



DecodedLabel

[cid:image002.png@01DA4948.23D733F0]



Why the second step? I have so much to learn.



-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of (WalzCraft) Jerry Forss
Sent: Wednesday, January 17, 2024 1:06 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: External RE: Base64Decode



Scott



Here is the pgm stripped down but getting same results.

I am trying different methods with QSys2.Base64Decode and systools.base64decode.

I get all @ returned.



**Free

Ctl-opt option(*SrcStmt : *NoDebugIO)

Dftactgrp(*NO)

ActGrp(*Caller);



Dcl-S DecodedLabel VarChar(4096) CCSID(1208);

Dcl-S Done Ind Inz('0');

Dcl-S False Ind Inz('0');

Dcl-S True Ind Inz('1');

Dcl-S Base64String VarChar(4096) CCSID(1208)

Inz('XlhBDQoNCl5GWCBTcGVlLURlZSBMb2dvDQpeRk81MTAsMTU0XkdGQSw3NTAsNzUwLDEwLCw6Ok4+

wMixRMDgsTDBDSjAxOCxLMDJMMDIsSzA4MDFGSjA4LEowMjAwM0YwMEMwMixKMDQwNzNDMDFGMDE4LEs+

wM0UzRjAxRkMwNCxJMDIwM0MxRjMxREMwMixJMDQwM0Y5QzdCOUM0MSxJMDgzREYxRjgzOUNGLDAwMTA+

3REUxRjg3QkNGOCwwMDIxQ0VGRDgwN0Y5RkMyLDAwNDFFQ0Y4STBGM0NDMSxJMDFGOEVJMDEwN0UwMDg+

sMDA4MEY4SjA2ODc3MDA0LEkwQzc4MDFGRTAwM0ExQzQsMDAxQzNDMDdGQzAzMUMzQzIsMDIzOTk4MUZ+

GRTdGMENGRSwwMDM3QzA3RkZDRTM4M0ZGMSwwNDNGQzBKRkMzMDNGMywwMDNFQzFJRjM5QzQxREEwOCw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KXkZPMjAsNzg3XkdCNjAsMywyXkZTDQpeRk80NDAsNTIwXkdCNjAsMywyXkZTDQpeRk8+

1MDAsNTIwXkdCMywyNzAsMl5GUw0KXkZPNDQwLDc4N15HQjYwLDMsMl5GUw0KDQpeRlggU29ydCBDb2R+

lXkZTDQpeRk81MTUsNzIwXkEwTiw1NCw3MF5GRDExXkZTDQpeRk81MzAsNzcwXkFETiwxOCwxMF5GRDA+

wMF5GUw0KDQpeWFoNCg==');



// Convert From Base64Data To ZPL

exec sql values QSys2.Base64_DeCode(:Base64String) Into :DecodedLabel;



*InLr = True;

Return;



-----Original Message-----

From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx<mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx>> On Behalf Of Scott Klement

Sent: Wednesday, January 17, 2024 12:44 PM

To: rpg400-l@xxxxxxxxxxxxxxxxxx<mailto:rpg400-l@xxxxxxxxxxxxxxxxxx>

Subject: Re: External RE: Base64Decode



Jerry,



I don't know how to help you with this. I feel that your original message is not technical enough for me to delve into it.



Can you provide a code example with hard-coded values that show what is provided on input, and lets me run it to see what you are getting on output, along with an explanation of what you are expecting to be different?





On 1/17/2024 8:27 AM, (WalzCraft) Jerry Forss wrote:

Is anyone actually using the base64decode from RPG and it's working?
Honestly the IBM doc is no help and my other research isn't bring up anything of a working example.
--

This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx<mailto:RPG400-L@xxxxxxxxxxxxxxxxxx> To subscribe, unsubscribe, or change list options,

visit: https://lists.midrange.com/mailman/listinfo/rpg400-l

or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx<mailto:RPG400-L-request@xxxxxxxxxxxxxxxxxx>

Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.



Please contact support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx> for any subscription related questions.









Subject to Change Notice:



WalzCraft reserves the right to improve designs, and to change specifications without notice.



Confidentiality Notice:



This message and any attachments may contain confidential and privileged information that is protected by law. The information contained herein is transmitted for the sole use of the intended recipient(s) and should "only" pertain to "WalzCraft" company matters. If you are not the intended recipient or designated agent of the recipient of such information, you are hereby notified that any use, dissemination, copying or retention of this email or the information contained herein is strictly prohibited and may subject you to penalties under federal and/or state law. If you received this email in error, please notify the sender immediately and permanently delete this email. Thank You



WalzCraft PO Box 1748 La Crosse, WI, 54602-1748 www.walzcraft.com<http://www.walzcraft.com<http://www.walzcraft.com%3chttp:/www.walzcraft.com>> Phone: 1-800-237-1326

--

This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx<mailto:RPG400-L@xxxxxxxxxxxxxxxxxx> To subscribe, unsubscribe, or change list options,

visit: https://lists.midrange.com/mailman/listinfo/rpg400-l

or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx<mailto:RPG400-L-request@xxxxxxxxxxxxxxxxxx>

Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.



Please contact support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx> for any subscription related questions.





Subject to Change Notice:

WalzCraft reserves the right to improve designs, and to change specifications without notice.

Confidentiality Notice:

This message and any attachments may contain confidential and privileged information that is protected by law. The information contained herein is transmitted for the sole use of the intended recipient(s) and should "only" pertain to "WalzCraft" company matters. If you are not the intended recipient or designated agent of the recipient of such information, you are hereby notified that any use, dissemination, copying or retention of this email or the information contained herein is strictly prohibited and may subject you to penalties under federal and/or state law. If you received this email in error, please notify the sender immediately and permanently delete this email. Thank You

WalzCraft PO Box 1748 La Crosse, WI, 54602-1748 www.walzcraft.com<http://www.walzcraft.com> Phone: 1-800-237-1326
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.




Subject to Change Notice:

WalzCraft reserves the right to improve designs, and to change specifications without notice.

Confidentiality Notice:

This message and any attachments may contain confidential and privileged information that is protected by law. The information contained herein is transmitted for the sole use of the intended recipient(s) and should "only" pertain to "WalzCraft" company matters. If you are not the intended recipient or designated agent of the recipient of such information, you are hereby notified that any use, dissemination, copying or retention of this email or the information contained herein is strictly prohibited and may subject you to penalties under federal and/or state law. If you received this email in error, please notify the sender immediately and permanently delete this email. Thank You

WalzCraft PO Box 1748 La Crosse, WI, 54602-1748
www.walzcraft.com<http://www.walzcraft.com> Phone: 1-800-237-1326

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.