Xref: utzoo comp.unix.questions:25089 comp.unix.ultrix:4367 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!nosc!humu!pegasus!pilikia!art From: art@pilikia.pegasus.com (Art Neilson) Newsgroups: comp.unix.questions,comp.unix.ultrix Subject: Re: EBCDIC to ASCII conversion under ULTRIX Message-ID: <1990Aug29.184831.1216@pilikia.pegasus.com> Date: 29 Aug 90 18:48:31 GMT References: <90240.091342HASKINS@MAINE.BITNET> Organization: Pilikia, Honolulu Lines: 35 In article <90240.091342HASKINS@MAINE.BITNET> HASKINS@MAINE.BITNET (Robert D. Haskins) writes: >Does anyone know how to convert a file that is in EBCDIC format to ASCII >format? Is there a command/program to do this under UNIX/ULTRIX ? If not, >does anybody know of a public domain program to do the conversion? This is really easy to write in C, just declare a static array of 256 unsigned chars and initialize it with the numeric values of the ASCII characters. Make sure the array position corresponds to the EBCDIC value as you will use the EBCDIC value as the indice into the array, like so: /* etoa.c */ #include typedef unsigned char byte; static byte ascii[256] = { initializers, go, here, }; main() { int c; while ((c = getchar()) != EOF) putchar(ascii[c]); } I can mail you both the ASCII and EBCDIC array declarations if you need them. -- Arthur W. Neilson III | ARPA: art@pilikia.pegasus.com Bank of Hawaii Tech Support | UUCP: uunet!ucsd!nosc!pegasus!pilikia!art