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


  • Subject: Re: Qdcxlate odditiles.
  • From: Scott Klement <klemscot@xxxxxxxxxxxx>
  • Date: Sun, 22 Apr 2001 02:59:49 -0500 (CDT)

On Fri, 20 Apr 2001, Jason Kleinemas wrote:
>
> Qdcxlate is giving me some interesting problems. When going from
> EBCDIC to ASCII it turns [ into ì. I'm using qtcpebc and qtcpasc from
> qusrsys. I also have tryed qebcdic and qascii from qsys. With the same
> types of results. Does any one know what other tables to try?

What you probably want to do is convert from codepage 437 (IBM PC ASCII)
to codepage 37 (EBCDIC) or vice-versa.   Of course, I could be completely
wrong, since I don't know what country you're in or what codepage they
typically use there...  

Alas, I do not know the appropriate *TBL object for that conversion.

One solution which may be a simple one would be to create your own table.
For example, typing:

CRTTBL TBL(MYTABLE) SRCFILE(*PROMPT) TBLTYPE(*CVT) BASETBL(QSYS/QEBCDIC)

Would bring up a screen that shows the mappings of the exising QEBCDIC
table, and allows you to change them to suit your needs, saving the result
as "MYTABLE".  Then you'd call QDCXLATE with "MYTABLE".

Another solution would be to use the iconv() API.  The programming is a 
bit more work, but it runs a bit faster...  

I have a service program for converting ASCII to/from EBCDIC.  Below
is that source, along with a simple example program.  (This is
somewhat simplified in that it only contains code relevant to converting)

To compile, do:
   1)  CRTRPGMOD ICONV SRCFILE(xxx/xxx) DBGVIEW(*LIST)
   2)  CRTRPGMOD TESTCONV SRCFILE(xxx/xxx) DBGVIEW(*LIST)
   3)  CRTSRVPGM SRVPGM(MYLIB/ICONV) EXPORT(*ALL) BNDDIR(QC2LE)
   4)  CRTPGM TESTCONV BNDSRVPGM(ICONV) ACTGRP(*NEW)

If this doesn't solve your problem, you'll need to determine what the
correct codepages are for your conversion, and replace "437" and "37"
in the examples...

HTH


-------------- Member: TESTCONV ----------------------------

     D/COPY ICONV_H
     D TestMe          S              5A

      ** Example of converting to EBCDIC:
     c                   eval      TestMe = x'48454c4c4f'
     c                   callp     ToEBCDIC(TestMe: %size(TestMe))

      ** And converting back to ASCII:
     c                   eval      TestMe = 'HELLO'
     c                   callp     ToASCII(TestMe: %size(TestMe))

     c                   eval      *inlr = *on


-------------- Member: ICONV_H -----------------------

     D ToASCII         PR            10I 0
     D   peBuffer                 32766A   options(*varsize)
     D   peBufSize                   10U 0 value

     D ToEBCDIC        PR            10I 0
     D   peBuffer                 32766A   options(*varsize)
     D   peBufSize                   10U 0 value


--------- member: ICONVR4 --------------------------------

     H NOMAIN 
     D/COPY ICONV_H

     D iconv_open      PR            52A   ExtProc('QtqIconvOpen')
     D   ToCode                        *   value
     D   FromCode                      *   value

     D iconv           PR            10I 0 ExtProc('iconv')
     D   Descriptor                  52A   value
     D   p_p_inbuf                     *   value
     D   in_left                     10U 0
     D   p_p_outbuf                    *   value
     D   out_left                    10U 0

     D InitIConv       PR            10I 0
     D    peWhich                    10A   const

     D dsToASC         DS
     D   ICORV_A                     10I 0
     D   ICOC_A                      10I 0 dim(12)
     D dsToEBC         DS
     D   ICORV_E                     10I 0
     D   ICOC_E                      10I 0 dim(12)

     D dsASCII         DS
     D   ascii_cp                    10I 0  INZ(437)
     D   ascii_ca                    10I 0  INZ(0)
     D   ascii_sa                    10I 0  INZ(0)
     D   ascii_ss                    10I 0  INZ(1)
     D   ascii_il                    10I 0  INZ(0)
     D   ascii_eo                    10I 0  INZ(1)
     D   ascii_r                      8A    INZ(*allx'00')

     D dsEBCDIC        DS
     D   ebcdic_cp                   10I 0  INZ(37)
     D   ebcdic_ca                   10I 0  INZ(0)
     D   ebcdic_sa                   10I 0  INZ(0)
     D   ebcdic_ss                   10I 0  INZ(1)
     D   ebcdic_il                   10I 0  INZ(0)
     D   ebcdic_eo                   10I 0  INZ(1)
     D   ebcdic_r                     8A    INZ(*allx'00')

     D wkXLInit        S              1A   INZ(*OFF)

      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      *  This initializes the iconv() API for character conversion
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P InitIConv       B
     D InitIConv       PI            10I 0
     D    peWhich                    10A   const

     C* Don't initialize more than once:
     c                   if        wkXLInit = *ON
     c                   return    0
     c                   endif

      * Initialize ASCII conv table:
     c                   if        peWhich <> '*EBCDIC'
     c                   eval      dsToASC = iconv_open(%addr(dsASCII):
     c                                                  %addr(dsEBCDIC))
     c                   if        ICORV_A < 0
     c                   return    -1
     c                   endif
     c                   endif

      * Initialize EBCDIC conv table:
     c                   if        peWhich <> '*ASCII'
     c                   eval      dsToEBC = iconv_open(%addr(dsEBCDIC):
     c                                                  %addr(dsASCII))
     c                   if        ICORV_E < 0
     c                   return    -1
     c                   endif
     c                   endif

     c                   eval      wkXLInit = *ON
     c                   return    0
     P                 E


      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      *  Translate a buffer from EBCDIC codepage 37 to ASCII 819
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P ToASCII         B                   Export
     D ToASCII         PI            10I 0
     D   peBuffer                 32766A   options(*varsize)
     D   peBufSize                   10U 0 value
     D p_Buffer        S               *
     c                   if        initiconv('*BOTH') < 0
     c                   return     -1
     c                   endif
     c                   eval      p_buffer = %addr(peBuffer)
     c                   return    iconv(dsToASC: %addr(p_buffer):peBufSize:
     c                                   %addr(p_buffer): peBufSize)
     P                 E


      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      *  Translate a buffer from ASCII codepage 819 to EBCDIC 37
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P ToEBCDIC        B                   Export
     D ToEBCDIC        PI            10I 0
     D   peBuffer                 32766A   options(*varsize)
     D   peBufSize                   10U 0 value
     D p_Buffer        S               *
     c                   if        initiconv('*BOTH') < 0
     c                   return     -1
     c                   endif
     c                   eval      p_buffer = %addr(peBuffer)
     c                   return    iconv(dsToEBC: %addr(p_buffer):peBufSize:
     c                                   %addr(p_buffer): peBufSize)
     P                 E

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