hi John,

I don't think it makes sense to store in ASCII in the database. After all, you're likely to want to do other things with your database besides this one program.

Why not just add code to your RPG program to convert it to ASCII prior to base64 encoding it?

Here's a trivial example in ILE RPG, that uses the IBM-supplied QDCXLATE program to convert from EBCDIC to ASCII:

D QDCXLATE PR ExtPgm('QDCXLATE')
D Len 5p 0 const
D data 32702a options(*varsize)
D table 10a const

D data s 5
/free
data = 'Hello';
QDCXLATE( %len(data)
: data
: 'QTCPASC' );

The above method is really easy to do, and it works. It can be used with any of the translation tables (*TBL objects) on your system. QTCPASC is an IBM-supplied table that translates to ASCII.

There are two big problems with QDCXLATE:

a) You can't use it to translate a single-byte character set to a double or mixed-byte character set.

b) In order to make it work properly with variant characters, you have to find (or create) a table that translates exactly the way you want. (there are many versions of ASCII and many versions of EBCDIC. Which one are you translating from? Which one are you translating to?)

A more sophisticated method of doing the translation (and one that requires more code) is to use the iconv() API. With iconv() you can provide the exact from/to CCSID and it'll translate between them. It also lets you work with double-byte and multi-byte character sets. But the code is more complex, so I'll leave you with the QDCXLATE API for now, and if you find that lacking, let me know and I'll post an iconv example.

But, at any rate, ASCII/EBCDIC translation is hardly part of Base64 encoding! Indeed, most of the time you use base64 encoding expressly because your data isn't text data!



John Allen wrote:

1)If I have the value "Hello" in my database field on the
System i (in EBCDIC) isn't there some method I can convert
it to an ASCII value before encoding it to Base64 so I end
up with the correct Base64 value the ASCII machine is
expecting, or just store it in my database field in ASCII
format (although it is actually an EBCDIC System)?
Example If the value were 123 in EBCDIC it would be stored
as x'F1F2F3' Could I store it as ASCII x'313233' then could
it be encoded to Base64 to be read in correctly by ASCII
system?


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.