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



Scott

Thank you for the great explanation.

This is my first time working with Base64 data. LOTS for me to learn.

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Scott Klement
Sent: Wednesday, January 17, 2024 4:18 PM
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Re: External RE: Base64Decode

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('XlhBDQoNCl5GWCBTcGVlLURlZSBMb2dvDQpeRk81MTAsMTU0XkdGQSw3NTAsNzUwL
DEwLCw6Ok4+


wMixRMDgsTDBDSjAxOCxLMDJMMDIsSzA4MDFGSjA4LEowMjAwM0YwMEMwMixKMDQwNzNDM
DFGMDE4LEs+


wM0UzRjAxRkMwNCxJMDIwM0MxRjMxREMwMixJMDQwM0Y5QzdCOUM0MSxJMDgzREYxRjgzO
UNGLDAwMTA+


3REUxRjg3QkNGOCwwMDIxQ0VGRDgwN0Y5RkMyLDAwNDFFQ0Y4STBGM0NDMSxJMDFGOEVJ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5BRE4sMTgsMTBeRkQ2MDg3OTcwOTI2X
kZTDQoNCl5+


GWCBTaWRlIEJhciBDb2RlXkZTDQpeRk81MTUsMzgwDQpeQlkyXkJDQiw2NSxOLE4sLEENC
l5GRFNQMDk+


wMDAwMjYwMTc5NDIzODAwXkZTDQoNCl5GTzIwLDUyMF5HQjYwLDMsMl5GUw0KXkZPMjAsN
TIwXkdCMyw+


yNzAsMl5GUw0KXkZPMjAsNzg3XkdCNjAsMywyXkZTDQpeRk80NDAsNTIwXkdCNjAsMywyX
kZTDQpeRk8+


1MDAsNTIwXkdCMywyNzAsMl5GUw0KXkZPNDQwLDc4N15HQjYwLDMsMl5GUw0KDQpeRlggU
29ydCBDb2R+


lXkZTDQpeRk81MTUsNzIwXkEwTiw1NCw3MF5GRDExXkZTDQpeRk81MzAsNzcwXkFETiwxO
CwxMF5GRDA+

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@xxxxxxxxx
range.com>> 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@xxxxxxxxxx
ange.com>

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%3c
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<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@xxxxxxxxxx
ange.com>

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

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.