First actual commit

This commit is contained in:
2024-05-02 21:19:44 +01:00
commit a5e08510f0
56 changed files with 19282 additions and 0 deletions
+72
View File
@@ -0,0 +1,72 @@
codePages = {
"0": "CP437",
"1": "KATAKANA",
"2": "CP850",
"3": "CP860",
"4": "CP863",
"5": "CP865",
"6": "Unknown",
"7": "Unknown",
"8": "Unknown",
"9": "Unknown",
"10": "Unknown",
"11": "Unknown",
"12": "Unknown",
"13": "Unknown",
"14": "Unknown",
"15": "Unknown",
"16": "CP1252",
"17": "CP866",
"18": "CP852",
"19": "CP858",
"20": "Unknown",
"21": "Unknown",
"22": "Unknown",
"23": "Unknown",
"24": "CP747",
"25": "CP1257",
"26": "Unknown",
"27": "Unknown",
"28": "CP864",
"31": "Unknown",
"32": "CP1255",
"53": "CP858",
"54": "CP852",
"55": "CP860",
"56": "CP861",
"57": "CP863",
"58": "CP865",
"59": "CP866",
"60": "CP855",
"61": "CP857",
"62": "CP862",
"63": "CP864",
"64": "CP737",
"65": "CP851",
"66": "CP869",
"68": "CP772",
"69": "CP774",
"71": "CP1252",
"72": "CP1250",
"73": "CP1251",
"74": "CP3840",
"76": "CP3843",
"77": "CP3844",
"78": "CP3845",
"79": "CP3846",
"80": "CP3847",
"81": "CP3848",
"83": "CP2001",
"84": "CP3001",
"85": "CP3002",
"86": "CP3011",
"87": "CP3012",
"88": "CP3021",
"89": "CP3041",
"90": "CP1253",
"91": "CP1254",
"92": "CP1256",
"93": "CP720",
"94": "CP1258",
"95": "CP775",
}
Binary file not shown.
+41
View File
@@ -0,0 +1,41 @@
#!/bin/env python
import json
import subprocess
PATH = "/home/esilva/Desktop/projetos/escpos-printer-db/dist/capabilities.json"
COMMAND = """iconv -f {charset} -t UTF-8 <<EOF | grep -v "^\\s*$"
$(printf '%b' "$(seq 128 255 | awk '{{printf("%c", $1)}}')")
EOF
"""
with open(PATH) as f:
capabilites = json.load(f)
# .profiles has the printer profiles
# our printer is .profiles.HZ-8360
# our code pages are in .profiles.HZ-8360.codePages
# .encodings has the available encodings and the iconv name
encodings = capabilites["encodings"]
codepages = capabilites["profiles"]["HZ-8360"]["codePages"]
for key in codepages:
name = encodings[codepages[key]]["name"]
if name.startswith("Unimplemented"):
continue
if "iconv" not in encodings[codepages[key]]:
continue
# if "data" not in encodings[codepages[key]]:
# continue
cp = encodings[codepages[key]]
cmd = COMMAND.format(charset = cp["iconv"])
subprocess.run(cmd, shell=True)
# print(cp["iconv"])
# print(json.dumps(capabilites["profiles"]["HZ-8360"]["codePages"]))
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
# List all available charsets using iconv
charsets=$(iconv -l)
function buildCharset() {
for ((i=128; i<256; i++)); do
hex=$(printf %x $i)
iconv -f "$1" -t UTF-8 <<< "$(printf "\x$hex")"
done | grep -v "^\s*$"
}
function printCharset() {
mapfile -t chars < <(buildCharset "$1")
counter=0
for c in "${chars[@]}"
do
echo -ne "$c "
counter=$((counter + 1))
if [ $counter == 16 ]; then echo ""; counter=0; fi
done
}
printCharset "CP437"