|
This is what I do:
Define arrays and work fields:
D ASCII S 1 DIM(255)
D EBCDIC S 1 DIM(255)
D WrkStr1 s 255
D WrkStr2 s 255
D DS
D BinValue 1 2B 0 INZ(0)
D BinChar 2 2
At program startup (one time) I load the ASCII and EBCDIC arrays:
C do 255 N
C z-add N BinValue
C eval %subst(WrkStr1:N:1) = BinChar
C enddo
C move WrkStr1 WrkStr2
C CALL 'QDCXLATE' 68
C PARM 255 DataLen
C PARM WrkStr1
C PARM 'QEBCDIC' XLateTable
C PARM 'QSYS' XLateTblLib
C CALL 'QDCXLATE' 68
C PARM 255 DataLen
C PARM WrkStr2
C PARM 'QASCII' XLateTable
C PARM 'QSYS' XLateTblLib
C do 255 N
C eval EBCDIC(N) = %subst(WrkStr1:N:1)
C eval ASCII(N) = %subst(WrkStr2:N:1)
C enddo
Then I convert the data by offsetting into the table:
C ToASCII begsr
C do XlateLen P
C eval BinChar = %subst(Buffer:P:1)
C eval N = BinValue
C N ifne 0
C move ASCII(N) BinChar
C endif
C eval %subst(Buffer:P:1) = BinChar
C enddo
C endsr
I hope this helps you.
> ----------
> From: Chris Bipes[SMTP:ChrisB@cross-check.com]
> Sent: Friday, August 27, 1999 8:15 AM
> To: RPG400 Help (E-mail)
> Subject: ASCII/EBCDIC Conversion
>
> Does anyone know the fasted and most efficient way to translate strings
> from ASCII to EBCDIC and back? I am currently using CALL QDCXLATE and
> want to use the TABLES that IBM provides, QSYS/QASCII & QSYS/QEBCDIC. Is
> there a way to load these tables into RPG tables at program init so I may
> use the XLATE opt code. Would this use less CPU cycles? Timing is
> critical in this application.
>
>
>
> Christopher K. Bipes mailto:ChrisB@Cross-Check.com
> Sr. Programmer/Analyst mailto:Chris_Bipes@Yahoo.com
> CrossCheck, Inc. http://www.cross-check.com
> 6119 State Farm Drive Phone: 707 586-0551 x 1102
> Rohnert Park CA 94928 Fax: 707 586-1884
>
> ***** Note to Recruiters *****
> I nor anyone that I know of is interested in any new and/or exciting
> positions. Please do not contact me.
>
>
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.