# 2024-08-13 - EPUB2TXT, Convert EPUB To Plain Text On DOS
Recently I wrote an XML parser in AWK [1].
I let it loose into the black abyss of DOS. It came back with books
in a bag of holding.
Now i am announcing epub2txt.awk, a script to convert EPUB files to
plain text for reading on DOS. It it relies on a bunch of utilities
to do this conversion. The only one i modified was UTF8TOCP.COM from
FreeDOS. I changed it to decode unknown Unicode codepoints into
\uHHHH and \UHHHHHHHH formats instead of just '?'.
It takes patience because the script can run for a long time.
Once completed, it produces several outputs.
The plaintxt/ directory contains short 8.3 filenames for all of the
images used in the EPUB; index.txt is UTF-8 encoded; index.dos is
CP437 encoded, has hard wrapped paragraphs, and has ASCII-art
transliterations for some Unicode codepoints.
The plaintxt/ directory would be a good one to zip up for viewing
on any DOS machine.
index.html gives a table of contents to read the EPUB content in
a web browser. In FreeDOS i can view this with inline images by
running:
links -g -mode 1024x768x256 index.html
I tested epub2txt [2] with nawk on FreeDOS 1.3 and MS-DOS 6.22. I
tested it with gawk, mawk, and nawk on Slackware 15. I advise
running on Unix if possible, then copying plaintxt over to DOS for
viewing.
See below [3] to view the source code.
See the directions in README.TXT and have fun!
p.s.
I found a very similar project written in C [4]. It is very fast.
It does not include references to images and external links. See
link below for code and details.
tags: bencollver,retrocomputing,technical
# Footnotes
(DIR) [1] XML parser in AWK
(DIR) [2] epub2txt for DOS
(HTM) [3] epub2txt source code
(DIR) [4] epub2txt2 converter written in C
# Tags
(DIR) bencollver
(DIR) retrocomputing
(DIR) technical