PlusLab.net – Looking for impossible IT project
ANSI Tools
ANSI Tools – tools for working with ANSI files and it’s SAUCE.
The main repository is on github at https://www.github.com/rambkk/ansi-tools
* Convert ANSI to HTML with cp437 to Unicode utf8
* Convert ANSI to JSON with cp437 to Unicode utf8
To make the output beautiful, the IBM VGA 8×16 font is recommended, this font is available at www.int10h.org
I have created this tool to simplify the process of transforming ANSI to HTML data (and also ANSI to JSON). This could be used for other conversions or manipulations as the ANSI data gets imported into Array Structure. Just copy the lib-php folder files, edit the ansi_to_html_simple.php appropriately, run it and you will get an the HTML output.
If you like this, do drop a hello note.
Simple example of a php file to do the conversion (you could even just do ansi_TO_HTML($input); )
:
<?php require_once("lib-php/ansi_lib.php"); $input=file_get_contents('CP437.ANS'); $option=['HTML_show_sauce'=>false]; echo ansi_TO_HTML($input,$option); ?>
Here is the list of default options some are just for HTML conversion and some are for JSON conversion:
$option=[ 'SAUCEhide' => true, 'HTML_format' => '<span style="color:%foreground%; background:%background%">%content%</span>', 'HTML_show_sauce' => true, 'HTML_header' => true, 'HTML_background' => 'black', 'HTML_foreground' => 'white', 'HTML_use_nbsp' => false, 'HTML_show_null' => ' ', 'width' => 'auto', 'use5m' => true, 'use7m' => true, 'ANSIfg' => '37', 'ANSIbg' => '40', 'cp437_to_utf8' => true, 'broken_pipe' => true, 'preserve_crlftab' => true, 'preserve_escape' => true, 'JSON_pretty_print' => true ]){
Sample ANSI to HTML output for all characters of cp437 displayed using Unicode UTF8 encoding
(Note: null character 0x00 is displayed using space ‘ ‘)
☺☻♥♦♣♠•◘○◙♂♀♪♫☼ ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&'()*+,-./ 0123456789:;<=>? @ABCDEFGHIJKLMNO PQRSTUVWXYZ[\]^_ `abcdefghijklmno pqrstuvwxyz{¦}~⌂ ÇüéâäàåçêëèïîìÄÅ ÉæÆôöòûùÿÖÜ¢£¥₧ƒ áíóúñѪº¿⌐¬½¼¡«» ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ └┴┬├─┼╞╟╚╔╩╦╠═╬╧ ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ αßΓπΣσµτΦΘΩδ∞φε∩ ≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ☺☻♥♦♣♠•◘○◙♂♀♪♫☼ ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&'()*+,-./ 0123456789:;<=>? @ABCDEFGHIJKLMNO PQRSTUVWXYZ[\]^_ `abcdefghijklmno pqrstuvwxyz{¦}~⌂ ÇüéâäàåçêëèïîìÄÅ ÉæÆôöòûùÿÖÜ¢£¥₧ƒ áíóúñѪº¿⌐¬½¼¡«» ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ └┴┬├─┼╞╟╚╔╩╦╠═╬╧ ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ αßΓπΣσµτΦΘΩδ∞φε∩ ≡±≥≤⌠⌡÷≈°∙·√ⁿ²■
ID |
SAUCE |
Version |
00 |
Title |
ANSITEST 001 github @rambkk |
Author |
Ram Narula |
Group |
www.pluslab.net |
Date |
20220511 |
FileSize |
4096 |
DataType |
1 |
FileType |
1 |
TInfo1 |
16 |
TInfo2 |
16 |
TInfo3 |
0 |
TInfo4 |
0 |
Comments |
5 |
TFlags |
3 |
TInfoS |
IBM VGA |
Comments |
|
1 |
1234567890123456789012345678901234567890123456789012345678901234 |
2 |
(maximum of 5 comments, each comment with exactly 64 characters) |
3 |
cp437 characters 0x00-0xFF 16 characters per line, 16 rows |
4 |
for demonstration/example/testing, if find useful, do say hello |
5 |
(c) Ram Narula ram@pluslab.com github @rambkk |