[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to convert Zardax WP files to plain text?



In article <m3aec1w8q5.fsf@irisfu.iri.tudelft.nl>, Stephen Harker
<harker@irisfu.iri.tudelft.nl> wrote:
> David See <dksee@hotmail.com> writes:
>
> > Any tips on how to convert Zardax word-processing
> > files to plain text files?
>
> It may not be of much help, but I remember that the ProDOS version of
> Zardax used plain text files and came with a utility to convert the
> DOS 3.3 version's binary files to plain text.  If someone has a copy
> of the ProDOS version they may be able to help.  I think I have a
> copy, but if I do it is in Australia and I am in the Netherlands,
> which is not of great help.

Thanks Stephen! However, it looks like I might not need to go
that far. Although I'm not sure how the formatting commands
are encoded, it looks like simply clearing the high bit of
each character works well enough for plain text. Here's a small
perl script I used:

#!/usr/local/bin/perl -w
use strict;

#
# Perl script to read Zardax WP (Apple2) text files, and
# convert them to plain PC text files.
#
# David See <dksee@hotmail.com>
# 2000-10-20
#

$/ = "\000";                    # Input record separator is null
character
my $preglob;

foreach $preglob (@ARGV) {      # Process each file in turn
  my $zardax;                   # glob for MS-DOS
  foreach $zardax (glob $preglob) {
    my $plain = $zardax;        # Copy the filename
    die "ERROR: $zardax already has .txt suffix" if $zardax =~
m/\.txt/i;
    $plain =~ s/\..{0,3}$//;    # remove the original suffix if present
    $plain .= ".txt";           # add .txt suffix instead
    print STDERR "Converting $zardax to $plain\n";
    die "ERROR: $plain already exists" if -e $plain;
    open ZARDAX, "<$zardax" or die "ERROR: can't open $zardax for
reading";
    open PLAIN, ">$plain" or die "ERROR: can't open $plain for
writing";
    $_ = <ZARDAX>;              # Read the input file in one chunk
    chomp;                      # Delete the trailing null character
    tr[\200-\377][\000-\177];   # Clear high bit
    s/\015/\015\012/g;          # Change CR to CR LF
    print PLAIN;                # And write it to the plain file
    close PLAIN;
    close ZARDAX;
  }
}


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