[comp.sys.atari.8bit] Conversions: ASCII -> ATASCII

fseipel@magnus.acs.ohio-state.edu (Frank E Seipel) (05/09/91)

 I am looking for a program I can run on a UNIX machine to convert ASCII to
ATASCII. I would like something that I can simply execute before an x-modem
download, and use with a pipe -- this way no extra files will be created.
I want to put USENET newsgroups on my new 8-bit BBS. While there are many
ASCII -> ATASCII converters for the 8-bit, it would be more convenient to
do the conversion on the UNIX machine. If worse comes to worse I can probably
change Trent Dudley's X/Y Modem download code to do the conversion (I think
I have source laying around somewhere).

 BTW ICD is dropping support of the 8-bit Atari completely at the end of
June.

 I have the new Z-Mag 192 and will send it up when I get a chance.

mwoodwar@yoda.eecs.wsu.edu (woodward matthew d - CS350) (05/10/91)

In article <1991May9.140834.21966@magnus.acs.ohio-state.edu> fseipel@magnus.acs.ohio-state.edu (Frank E Seipel) writes:
>
> I am looking for a program I can run on a UNIX machine to convert ASCII to
>ATASCII. I would like something that I can simply execute before an x-modem
>download, and use with a pipe -- this way no extra files will be created.
>I want to put USENET newsgroups on my new 8-bit BBS. While there are many
>ASCII -> ATASCII converters for the 8-bit, it would be more convenient to
>do the conversion on the UNIX machine. If worse comes to worse I can probably
>change Trent Dudley's X/Y Modem download code to do the conversion (I think
>I have source laying around somewhere).
>
> BTW ICD is dropping support of the 8-bit Atari completely at the end of
>June.
>
> I have the new Z-Mag 192 and will send it up when I get a chance.

here is a basic skeleton (in C) to do what you want to do.  This task could
be pretty easily done in Atari BASIC on the Atari side, but it will definetly
go MUCH quicker on the UNIX end (unless the Unix machine is overworked or a
dog).

-----------------------cut here------------------------------------

#include <stdio.h>

/* compile command:  cc ataconv.c -o ataconv */
/* this program will take a filename on the command line for input. */
/* because I was using it for another purpose, the output ALWAYS goes */
/* to standard output so you can do the following: */

/* ataconv ascii.file > atascii.file */
/* ataconv < ascii.file > atascii.file */
/* the first two have the same end result */

/* maybe you can do this (this is how our system works) */
/* ataconv ascii.file | xmodem -st */
/* pipe ataconv's output to the xmodem program (most efficient if that is */
/*    your end goal. */

/* note:  The shell of this program works--I used it for a TEX filter.  you */
/* will need to define the  defines below.  The atari conversion part has */
/* not been debugged.  (I think it's okay, though.)  I am leaving, so if you*/
/* have any problems, I probably won't answer for at least 3 weeks.       */


#define UNIX_LF \XXX    /* linefeed where XXX is a 3-digit  octal constant */
                        /* for ctrl-M. */
#define UNIX_CR \XXX    /* unix CR */
#define ATARI_CR \XXX   /* atari CR value */

main(argc, argv)
     int argc;
     char **argv;
{
  FILE *fp;
  int c;

  if(argc < 2)
    fp = stdin;
  else{
    fp = fopen(argv[1], "r");
    if (fp == NULL){
      fprintf(stderr, "bad file %s\n", argv[1]);
      exit(1);
    }
  }


  while((c = fgetc(fp)) != EOF){
    if(isprint(c))   /* printables go out as-is */ 
      putchar(c);    /* you might want to filter the clearscreen which is */
    else             /* one of the curly braces.                          */
      switch (c){	
      case UNIX_LF:          /* strip linefeeds */
	break;              /* you may, depending on UNIX implementation */
                            /* want to strip CRs and convert LF          */

      case UNIX_CR:          /* convert UNIX c/r to ATARI */
	putchar(ATARI_CR);
	break;
	case 

      /* convert any other characters you want in a similar manner */

  }
  
  exit(0);
}

/* not a whole lot of error-checking here...be careful, don't toast your */
/* until you check your results */

/* disclaimer:  I assume no responsiblity for the fitness of this code. */
/*              IT'S ONLY A KLUDGE! :)                                  */

/* Matt Woodward mwoodwar@yoda.eecs.wsu.edu */

Chris_F_Chiesa@cup.portal.com (05/14/91)

Frank Seipel asks about ASCII <--> ATASCII conversion on a UNIX system.

Frank, the "standard" (IS there any such thing? :-) ) UNIX package contains
a utility called "tr" which can be convinced to do what you want.  "tr"
takes a UNIX character stream (a file, pipe, etc.) and substitutes charac-
ters FROM a set you specify, with OTHER characters from ANOTHER set you 
specify.  Most people use it for, say, ROT13 transforms, up- or down-casing,
etc., but you can ALSO use it for ASCII/ATASCII conversion!

The ASCII to ATASCII conversion consists of replacing all UNIX "newline"
characters with ATASCII "eol" characters, and the reverse conversion is --
of course -- the opposite.

Without further ado, the commands to do the deeds:


ASCII to ATASCII:

     tr <inputfile >outputfile '\012' '\233'

ATASCII to ASCII:

     tr <inputfile >outputfile '\233' '\012'~r

I was as thrilled to discover this a few years ago, as I'm sure a few
people are to hear it today!  Enjoy!  :-)

Chris Chiesa
  Chris_F_Chiesa@cup.portal.com

Chris_F_Chiesa@cup.portal.com (05/17/91)

Good grief.  I just noticed a typo in a very bad place in my recent posting
about using UNIX 'tr' to translate between ASCII and ATASCII text file formats.

The command for translating ATASCII to ASCII came out as 

     tr <inputfile >outputfile '\233' '\012'~r

... but the "~r" on the end is LINE NOISE!

The command should end with the closing quote after the number 012.

My apologies for letting this get through in the first place!  I'm horri-
fied...

Chris Chiesa
  Chris_F_Chiesa@cup.portal.com