ASCII & EBCDIC Conversion 
Author Message
 ASCII & EBCDIC Conversion

Hello Everyone,

Could anyone help me to converse a ASCII char-string
to an EBCDIC char-string ( I mean writting a PL/I function) , please ?

Thanks a lot,

L.



Sat, 04 Jan 2003 03:00:00 GMT  
 ASCII & EBCDIC Conversion


Quote:
> Hello Everyone,

> Could anyone help me to converse a ASCII char-string
> to an EBCDIC char-string ( I mean writting a PL/I function) , please ?

The function exists, it is named TRANSLATE and is a standard PL/I function.

From the manual:

TRANSLATE(x,y,z)

x       Character expression to be searched for possible translation of its
characters.

y       Character expression containing the translation values of
characters.

z       Character expression containing the characters that are to be
translated.  If z is
        omitted, a string of 256 characters is assumed; it contains one
instance of each
        EBCDIC code arranged in ascending collating sequence (hexadecimal
00
        through FF).

TRANSLATE operates on each character of x as follows:

If a character in x is found in z, the character in y that corresponds to
that in z is
copied to the result; otherwise, the character in x is copied directly to
the result.  If z
contains duplicates, the leftmost occurrence is used.

y is padded with blanks, or truncated, on the right to match the length of
z.

All you have to supply is the two alphabets, in ASCII and EBCDIC codes.

go.



Sat, 04 Jan 2003 03:00:00 GMT  
 ASCII & EBCDIC Conversion

Quote:

> Hello Everyone,

> Could anyone help me to converse a ASCII char-string
> to an EBCDIC char-string ( I mean writting a PL/I function) , please ?

> Thanks a lot,

> L.

Here is my take on it.  Just %INCLUDE ASCEBC, and then
   TRANSLATE( your string, EBCDIC);
Translate EBCDIC to ASCII analogously.

The tables are EBCDIC code page 1047 and ASCII code page 819.  YMMV. (no
control characters except FF and ESC).

-------- ASCII to EBCDIC (member ASCEBC) -------

/********************************************************************/
 /*      ASCII TO EBCDIC -- CODEPAGE 819->1047                       */
 /********************************************************************/
 DCL     EBCDIC_1047     (32)CHAR(8)        INIT
        ('0000000000000000'X ,    /* ASCII 00-07 */
         '000000000C000000'X ,    /* ASCII 08-0F */
         '0000000000000000'X ,    /* ASCII 10-17 */
         '0000002700000000'X ,    /* ASCII 18-1F */
         '405A7F7B5B6C507D'X ,    /* ASCII 20-27 */
         '4D5D5C4E6B604B61'X ,    /* ASCII 28-2F */
         'F0F1F2F3F4F5F6F7'X ,    /* ASCII 30-37 */
         'F8F97A5E4C7E6E6F'X ,    /* ASCII 38-3F */
         '7CC1C2C3C4C5C6C7'X ,    /* ASCII 40-47 */
         'C8C9D1D2D3D4D5D6'X ,    /* ASCII 48-4F */
         'D7D8D9E2E3E4E5E6'X ,    /* ASCII 50-57 */
         'E7E8E9ADE0BD5F6D'X ,    /* ASCII 58-5F */
         '7981828384858687'X ,    /* ASCII 60-67 */
         '8889919293949596'X ,    /* ASCII 68-6F */
         '979899A2A3A4A5A6'X ,    /* ASCII 70-77 */
         'A7A8A9C04FD0A100'X ,    /* ASCII 78-7F */
         '0000000000000000'X ,    /* ASCII 80-87 */
         '0000000000000000'X ,    /* ASCII 88-8F */
         '0000000000000000'X ,    /* ASCII 90-97 */
         '0000000000000000'X ,    /* ASCII 98-9F */
         '41AA4AB19FB26AB5'X ,    /* ASCII A0-A7 */
         'BBB49A8AB0CAAFBC'X ,    /* ASCII A8-AF */
         '908FEAFABEA0B6B3'X ,    /* ASCII B0-B7 */
         '9DDA9B8BB7B8B9AB'X ,    /* ASCII B8-BF */
         '6465626663679E68'X ,    /* ASCII C0-C7 */
         '7471627378757677'X ,    /* ASCII C8-CF */
         'AC69EDEEEBEFECBF'X ,    /* ASCII D0-D7 */
         '80FDFEFBFCBA8E59'X ,    /* ASCII D8-DF */
         '4445424643479C48'X ,    /* ASCII E0-E7 */
         '5451525358555657'X ,    /* ASCII E8-EF */
         '8C49CDCECBCFCCE1'X ,    /* ASCII F0-F7 */
         '70DDDEDBDC8D8EDF'X ),   /* ASCII F8-FF */
         EBCDIC              CHAR(256)      defined EBCDIC_1047;

-------- EBCDIC to ASCII (member EBCASC) ------
 /********************************************************************/
 /*      EBCDIC TO ASCII -- CODEPAGE 1047->819                  */
/********************************************************************/
 DCL     ASCII_819       (32)CHAR(8)        INIT
        ('0000000000000000'X ,    /* EBCDIC 00-07 */
         '000000000C000000'X ,    /* EBCDIC 08-0F */
         '0000000000000000'X ,    /* EBCDIC 10-17 */
         '0000000000000000'X ,    /* EBCDIC 18-1F */
         '000000000000001B'X ,    /* EBCDIC 20-27 */
         '0000000000000000'X ,    /* EBCDIC 28-2F */
         '0000000000000000'X ,    /* EBCDIC 30-37 */
         '0000000000000000'X ,    /* EBCDIC 38-3F */
         '20A0E2E4E0E1E3E5'X ,    /* EBCDIC 40-47 */
         'E7F1A22E3C282B7C'X ,    /* EBCDIC 48-4F */
         '26E9EAEBE8EDEEEF'X ,    /* EBCDIC 50-57 */
         'ECDF21242A293B5E'X ,    /* EBCDIC 58-5F */
         '2D2FC2C4C0C1C3C5'X ,    /* EBCDIC 60-67 */
         'C7D1A62C255F3E3F'X ,    /* EBCDIC 68-6F */
         'F8C9CACBC8CDCECF'X ,    /* EBCDIC 70-77 */
         'CC603A2340273D22'X ,    /* EBCDIC 78-7F */
         'D861626364656667'X ,    /* EBCDIC 80-87 */
         '6869ABBBF0FCFEB1'X ,    /* EBCDIC 88-8F */
         'B06A6B6C6D6E6F70'X ,    /* EBCDIC 90-97 */
         '7172AABAE6B8C6A4'X ,    /* EBCDIC 98-9F */
         'B57E737475767778'X ,    /* EBCDIC A0-A7 */
         '797AA1BFD05BDEAE'X ,    /* EBCDIC A8-AF */
         'ACA3A5B7A9A7B6BC'X ,    /* EBCDIC B0-B7 */
         'BDBEDDA8AF5DB4D7'X ,    /* EBCDIC B8-BF */
         '7B41424344454647'X ,    /* EBCDIC C0-C7 */
         '4849ADF4F6F2F3F5'X ,    /* EBCDIC C8-CF */
         '7D4A4B4C4D4E4F50'X ,    /* EBCDIC D0-D7 */
         '5152B9FBFCF9FAFF'X ,    /* EBCDIC D8-DF */
         '5CF7535455565758'X ,    /* EBCDIC E0-E7 */
         '595AB2D4D6D2D3D5'X ,    /* EBCDIC E8-EF */
         '3031323334353637'X ,    /* EBCDIC F0-F7 */
         '3839B3DBDCD9DA00'X ),   /* EBCDIC F8-FF */
         ASCII               CHAR(256)      defined ascii_819;



Sat, 04 Jan 2003 03:00:00 GMT  
 ASCII & EBCDIC Conversion
On VA PL/I, there are BIFs for this. The Guide has info on code page
customization.
For OS PL/I or PL/I for MVS, use TRANSLATE.


Quote:
> Hello Everyone,

> Could anyone help me to converse a ASCII char-string
> to an EBCDIC char-string ( I mean writting a PL/I function) , please ?

> Thanks a lot,

> L.



Sun, 05 Jan 2003 03:00:00 GMT  
 ASCII & EBCDIC Conversion
Thanks, Peter!
:-)
Long
Quote:


> > Hello Everyone,

> > Could anyone help me to converse a ASCII char-string
> > to an EBCDIC char-string ( I mean writting a PL/I function) , please ?

> > Thanks a lot,

> > L.

> Here is my take on it.  Just %INCLUDE ASCEBC, and then
>    TRANSLATE( your string, EBCDIC);
> Translate EBCDIC to ASCII analogously.

> The tables are EBCDIC code page 1047 and ASCII code page 819.  YMMV. (no
> control characters except FF and ESC).

> -------- ASCII to EBCDIC (member ASCEBC) -------

> /********************************************************************/
>  /*      ASCII TO EBCDIC -- CODEPAGE 819->1047                       */
>  /********************************************************************/
>  DCL     EBCDIC_1047     (32)CHAR(8)        INIT
>         ('0000000000000000'X ,    /* ASCII 00-07 */
>          '000000000C000000'X ,    /* ASCII 08-0F */
>          '0000000000000000'X ,    /* ASCII 10-17 */
>          '0000002700000000'X ,    /* ASCII 18-1F */
>          '405A7F7B5B6C507D'X ,    /* ASCII 20-27 */
>          '4D5D5C4E6B604B61'X ,    /* ASCII 28-2F */
>          'F0F1F2F3F4F5F6F7'X ,    /* ASCII 30-37 */
>          'F8F97A5E4C7E6E6F'X ,    /* ASCII 38-3F */
>          '7CC1C2C3C4C5C6C7'X ,    /* ASCII 40-47 */
>          'C8C9D1D2D3D4D5D6'X ,    /* ASCII 48-4F */
>          'D7D8D9E2E3E4E5E6'X ,    /* ASCII 50-57 */
>          'E7E8E9ADE0BD5F6D'X ,    /* ASCII 58-5F */
>          '7981828384858687'X ,    /* ASCII 60-67 */
>          '8889919293949596'X ,    /* ASCII 68-6F */
>          '979899A2A3A4A5A6'X ,    /* ASCII 70-77 */
>          'A7A8A9C04FD0A100'X ,    /* ASCII 78-7F */
>          '0000000000000000'X ,    /* ASCII 80-87 */
>          '0000000000000000'X ,    /* ASCII 88-8F */
>          '0000000000000000'X ,    /* ASCII 90-97 */
>          '0000000000000000'X ,    /* ASCII 98-9F */
>          '41AA4AB19FB26AB5'X ,    /* ASCII A0-A7 */
>          'BBB49A8AB0CAAFBC'X ,    /* ASCII A8-AF */
>          '908FEAFABEA0B6B3'X ,    /* ASCII B0-B7 */
>          '9DDA9B8BB7B8B9AB'X ,    /* ASCII B8-BF */
>          '6465626663679E68'X ,    /* ASCII C0-C7 */
>          '7471627378757677'X ,    /* ASCII C8-CF */
>          'AC69EDEEEBEFECBF'X ,    /* ASCII D0-D7 */
>          '80FDFEFBFCBA8E59'X ,    /* ASCII D8-DF */
>          '4445424643479C48'X ,    /* ASCII E0-E7 */
>          '5451525358555657'X ,    /* ASCII E8-EF */
>          '8C49CDCECBCFCCE1'X ,    /* ASCII F0-F7 */
>          '70DDDEDBDC8D8EDF'X ),   /* ASCII F8-FF */
>          EBCDIC              CHAR(256)      defined EBCDIC_1047;

> -------- EBCDIC to ASCII (member EBCASC) ------
>  /********************************************************************/
>  /*      EBCDIC TO ASCII -- CODEPAGE 1047->819                  */
> /********************************************************************/
>  DCL     ASCII_819       (32)CHAR(8)        INIT
>         ('0000000000000000'X ,    /* EBCDIC 00-07 */
>          '000000000C000000'X ,    /* EBCDIC 08-0F */
>          '0000000000000000'X ,    /* EBCDIC 10-17 */
>          '0000000000000000'X ,    /* EBCDIC 18-1F */
>          '000000000000001B'X ,    /* EBCDIC 20-27 */
>          '0000000000000000'X ,    /* EBCDIC 28-2F */
>          '0000000000000000'X ,    /* EBCDIC 30-37 */
>          '0000000000000000'X ,    /* EBCDIC 38-3F */
>          '20A0E2E4E0E1E3E5'X ,    /* EBCDIC 40-47 */
>          'E7F1A22E3C282B7C'X ,    /* EBCDIC 48-4F */
>          '26E9EAEBE8EDEEEF'X ,    /* EBCDIC 50-57 */
>          'ECDF21242A293B5E'X ,    /* EBCDIC 58-5F */
>          '2D2FC2C4C0C1C3C5'X ,    /* EBCDIC 60-67 */
>          'C7D1A62C255F3E3F'X ,    /* EBCDIC 68-6F */
>          'F8C9CACBC8CDCECF'X ,    /* EBCDIC 70-77 */
>          'CC603A2340273D22'X ,    /* EBCDIC 78-7F */
>          'D861626364656667'X ,    /* EBCDIC 80-87 */
>          '6869ABBBF0FCFEB1'X ,    /* EBCDIC 88-8F */
>          'B06A6B6C6D6E6F70'X ,    /* EBCDIC 90-97 */
>          '7172AABAE6B8C6A4'X ,    /* EBCDIC 98-9F */
>          'B57E737475767778'X ,    /* EBCDIC A0-A7 */
>          '797AA1BFD05BDEAE'X ,    /* EBCDIC A8-AF */
>          'ACA3A5B7A9A7B6BC'X ,    /* EBCDIC B0-B7 */
>          'BDBEDDA8AF5DB4D7'X ,    /* EBCDIC B8-BF */
>          '7B41424344454647'X ,    /* EBCDIC C0-C7 */
>          '4849ADF4F6F2F3F5'X ,    /* EBCDIC C8-CF */
>          '7D4A4B4C4D4E4F50'X ,    /* EBCDIC D0-D7 */
>          '5152B9FBFCF9FAFF'X ,    /* EBCDIC D8-DF */
>          '5CF7535455565758'X ,    /* EBCDIC E0-E7 */
>          '595AB2D4D6D2D3D5'X ,    /* EBCDIC E8-EF */
>          '3031323334353637'X ,    /* EBCDIC F0-F7 */
>          '3839B3DBDCD9DA00'X ),   /* EBCDIC F8-FF */
>          ASCII               CHAR(256)      defined ascii_819;



Sun, 05 Jan 2003 03:00:00 GMT  
 ASCII & EBCDIC Conversion

Quote:
> Could anyone help me to converse a ASCII char-string
> to an EBCDIC char-string ( I mean writting a PL/I function) , please ?

I don't know about the other PL/1 compilers but the VisualAge PL/1
compiler for Windows has a couple of built-in functions to do this.

PLIEBCDIC(x,y,z)
   x is a pointer to the ASCII input string
   y is a pointer to the EBCDIC output string
   z is the number of bytes to convert.

PLIASCII(x,y,z)
   x is a pointer to the EBCDIC input string
   y is a pointer to the ASCII output string
   z is the number of bytes to convert.

I hope this helps.
Randy Gress

Sent via Deja.com http://www.deja.com/
Before you buy.



Sun, 05 Jan 2003 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. ASCII/EBCDIC conversions in Smalltalk

2. EBCDIC to ASCII conversion

3. Signed Numeric ASCII-EBCDIC conversion question

4. EBCDIC to ASCII Conversion

5. NetExpress and ASCII/EBCDIC Conversions

6. Need converter program to translate ascii to ebcdic in mixes ascii/binary file

7. VRML 1.0 ASCII conversion & Linux

8. EBCDIC to ASCII

9. Oracle Connect ASCII-EBCDIC Conflict!

10. ASCII to EBCDIC

11. EBCDIC TO ASCII

12. converting EBCDIC to ASCII

 

 
Powered by phpBB® Forum Software