EBCDIC <--> ASCII conversion

Dave Wells adw at otter.hpl.hp.com
Tue Oct 16 18:57:19 AEST 1990


Charles Noren at Martin Marietta I&CS, Denver CO:

>We are communicating between Sun 3 (with SunOS 4.0.3) and an
>IBM Mainframe (don't know the model, we're not IBM jocks)
>via TCP/IP.  Our question, is there any program in Netland
>that converts back and forth between EBCDIC and ASCII
>(preferrably in C, but we will take any example)?

Jonathan I. Kamens at Massachusetts Institute of Technology:

|  The Unix program "dd" does this.  In particular, the "conv=ascii" option
|converts EBCDIC to ASCII, and the "conv=ebcdic" option goes the other way.
|  See the man page for more information.

It's particularly worth noting this (from that dd man page):

          ASCII and EBCDIC conversion tables are taken from the 256-
          character ACM standard, Nov, 1968.  The ibm conversion,
          while less widely accepted as a standard, corresponds better
          to certain IBM print train conventions.  There is no
                                                   ^^^^^^^^^^^
          universal solution.
          ^^^^^^^^^^^^^^^^^^^

If you're translating "ordinary text files", dd will probably do the trick.
If you're hoping to translate files or streams containing "unusual"
characters (e.g. control codes for a graphics terminal), the exact
translation table may well vary on a per-site basis.

Dave Wells



More information about the Comp.lang.c mailing list