receipt-print-hq / escpos-tools

Utilities to read ESC/POS print data
MIT License
201 stars 73 forks source link

Set escpos binary file encoding type in environment variable #67

Open PratikBodawala opened 4 years ago

PratikBodawala commented 4 years ago

61

Setting the Environment variable "SOURCE_ENCODING" for other than CP437 encoding

PratikBodawala commented 4 years ago

Hello, @welcoMattic, @mike42 Could you review my PR and provide feedback?

mike42 commented 4 years ago

Hi,

I've taken a look at the code. Can you share an example file which you're running this with, and the make/model of printer that you use?

I would be interested to know whether I can make an alternative solution work for your use case, by adjusting the current code page each time we encounter an ESC t (select code page) command in the file. A single file will often access characters from many different code pages, and this would be the correct way to handle that.

The default code page (encoding to assume if none is specified in the actual file) is another matter entirely, and an environment variable is certainly a good way to handle that.

PratikBodawala commented 4 years ago

With environment variable

image

Without environment variable

image

model: HOP-801

As I mentioned in issue #61, I need 1/4, 1/2, and 3/4. The default charset has 1/4 and 1/2. But not 3/4 so, I search for other encodings which are supported by this model, so, latin1 is supported and print just fine. but when I convert it to html it was decoding from wrong charset. Following file in latin1 charset.

test90.txt