receipt-print-hq / escpos-printer-db

Database of ESC/POS thermal receipt printers
https://mike42.me/escpos-printer-db/
Creative Commons Attribution 4.0 International
111 stars 51 forks source link

Resources for Inferring CodePages? #66

Open ghost opened 3 years ago

ghost commented 3 years ago

Hi folks, thanks for creating this invaluable resource.

I've bought what appears to be a whitelabel version of the "Welquic" printer from this article - it is visually identical except it lacks the "Welquic" brand. I have it working, mostly, using python-escpos.

I am having character encoding issues for common characters like áéíóú so I believe I need to create a profile that maps code pages. The printer helpfully prints out a debug page mapping codes to codepages, but not all are given actual codepage names, just occult titles like "(Katakana)". Yes, this is the exact issue that Mike wrote this article about. I have translated that into bad Python as the following, and for the "(Katakana)" page it returns the same results as Mike's example in the blog post.

# p = printer

foo = b'\x1b@\x1bt' + b'\x01' + b'\x1bE\x01Code page 1\x1bE\x00\n' + b'\x1bE\x01  0123456789ABCDEF0123456789ABCDEF\x1bE\x00\n' 

chars = bytearray(128) 
for i in range(128): 
    chars[i] = i + 128 

for y in range(0,4): 
    row = b' ' 
    rowHeader = b"\x1bE\x01" + [b'8', b'A', b'C', b'E'][y] + b"\x1bE\x00" 
    row = chars[(y*32) : ((y*32) + 32)] 
    foo += rowHeader + b' ' + row + b'\n' 

p._raw(foo)
p.cut()

So my question is: Given the ability to instruct the printer to print codepages with names like "(Vietnam)", how do I go from this to an official codepage name that I can put into a profile for the ESC/POS Printer DB for this printer model? Only some of the codepages are documented on Wikipedia, even assuming that I could wade through candidate codepage names to find a match by brute force.

There are a few tens of codepages for this printer so I don't think I'm likely to document them all, but I'd like to be as helpful as possible all the same.

Thanks!