There are two issues involved:
- Encoding needs to be converted from CP 437 to your terminal encoding. This is done using
iconv -f 437 input_file.ANS
as you already discovered. - ANSI escape sequences need to be fixed.
In dman-warrior.ANS
there are two types of escape sequences used. The first one is used only once and is the first thing in the file. It is ESC[0m
and it resets all graphics mode attributes. The second type is ESC[<value>C
(e.g. ESC[24C
) and it moves the cursor <value>
characters forward (to the right). If the cursor cannot go any further, it stops. You can test it in your terminal using this shell command:
printf '\x1b[10000CXYZ\n'
It should look like this:
|$ printf '\x1b[10000CXYZ\n' |
| X|
|YZ |
|$ |
The image file has only a few lines (delimited by CRLF). Each is wrapped to the terminal width (80 columns), thus producing several screen lines.
The image is OK up to the first screen line starting with ESC[<value>C
escape sequence in the middle of a file line.
- Terminal writes the previous screen line, ending at the last column.
- The
ESC[<value>C
escape sequence is met. Being at the last column, cursor cannot go any further to the right, so the sequence is ignored. - Next comes a character which forces the line to be wrapped and is printed on the following screen line.
The new screen line is missing the empty space which should have been skipped by the escape sequence.
Possible solutions
- Somehow alter the behavior of the terminal emulator. (I have no idea how, except compiling a tweaked custom version.)
- Explicitly break lines. If the
ESC[<value>C
is the only escape sequence used, it should by easy enough to write a program that fixes the images.