EBCDIC to ASCII conversion under ULTRIX

Art Neilson art at pilikia.pegasus.com
Thu Aug 30 04:48:31 AEST 1990


In article <90240.091342HASKINS at MAINE.BITNET> HASKINS at 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 <stdio.h>

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 at pilikia.pegasus.com
Bank of Hawaii Tech Support	| UUCP: uunet!ucsd!nosc!pegasus!pilikia!art



More information about the Comp.unix.ultrix mailing list