It's easy to find ASCII tables online but it seems that Puppy doesn't include an offline version, so I wrote one myself.
I started with a table generated with awk before I found that in older Puppies the file /usr/share/cups/charmaps/windows-1252.txt and in newer Puppies the file /usr/lib/aspell/cp1252.cset include descriptions for each character (though not the characters themselves). They also contain Unicode codepoints for characters in extended ASCII range 0x80-0x9F of codepage 1252. These codepoints do not correspond with the hex values of this range and therefore can't easily be generated otherwise.
I intend to integrate following script into MMview but before I do I would like to know
1) if it contains unexpected bugs
2) if it could possibly be simplified
3) if either one of the 2 files I mentioned is indeed present in all Puppies, which would eliminate the need for the fall-back option /tmp/asciimap.tmp
Thanks.
Code: Select all
#!/bin/bash
LOCATION_1=/usr/share/cups/charmaps/windows-1252.txt
LOCATION_2=/usr/lib/aspell/cp1252.cset
LOCATION_3=/usr/lib64/aspell/cp1252.cset
if [[ -s $LOCATION_1 ]];then CHARMAP=$LOCATION_1
elif [[ -s $LOCATION_2 ]];then CHARMAP=$LOCATION_2
elif [[ -s $LOCATION_3 ]];then CHARMAP=$LOCATION_3
else #may never be needed as one of above should always be present
CHARMAP=/tmp/asciimap.tmp
awk '
BEGIN {
for (i=0 ;i<=127;i++) printf "%02X\t%04X\t%s\n",i,i,"#"
for (i=128;i<=159;i++) printf "%02X\t%04X_<control_character>\t%s\n",i,i,"#"
for (i=160;i<=255;i++) printf "%02X\t%04X\t%s\n",i,i,"#"
}' > $CHARMAP
fi
LC_ALL=C awk '
BEGIN {
hline="---------------------------------------------------------"
print "=========== ASCII Table ==========\n\nDEC\tHEX\tCHR\tCODEPNT NAME\n"hline
}
/^[0-9A-F]/{ # process only lines starting with hex characters
text=substr($0, match($0,/#/)+1) # extract from position of first encountered #, plus 1 to excl. #
sub(/^ /,"",text) # remove leading space from text (cp1252.cset)
$1=substr($1, match($1,/x/)+1) # remove 0x from 0xnn (windows-1252.txt) or keep nn (cp1252.cset)
dec=strtonum("0x" $1) # hex to dec
cpnt="U+"substr($2, match($2,/x/)+1)# remove 0x from 0xnnnn (windows-1252.txt) or keep nnnn (cp1252.cset)
if (cpnt ~ /#/) cpnt="U+00"$1 # if cpnt rendered as U+#UNDEFINED (windows-1252.txt)
if (dec<32||dec==127) char=""; else char=sprintf("%c",dec)
if (dec==7) text="BELL (esc \\a)"
if (dec==8) text="BACKSPACE (esc \\b)"
if (dec==9) {text="HORIZONTAL TABULATION (esc \\t)";char="TAB"}
if (dec==10) {text="LINE FEED (esc \\n)";char="LF" }
if (dec==11) text="VERTICAL TABULATION (esc \\v)"
if (dec==12) text="FORM FEED (esc \\f)"
if (dec==13) {text="CARRIAGE RETURN (esc \\r)";char="CR"}
if ($1==20) print hline"\nPrintable ASCII\n"hline
if ($1==80) print hline"\nExtended ASCII (example: codepage 1252)\n"hline
printf "%03d\t%s\t%s\t%s\t%s\n" ,dec,$1,char,cpnt,text
}' $CHARMAP | iconv -c -f CP1252 -t UTF-8 | gxmessage -file -
.