escpos-tools icon indicating copy to clipboard operation
escpos-tools copied to clipboard

Set escpos binary file encoding type in environment variable

Open PratikBodawala opened this issue 5 years ago • 3 comments

#61

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

PratikBodawala avatar Feb 10 '20 06:02 PratikBodawala

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

PratikBodawala avatar Feb 10 '20 06:02 PratikBodawala

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.

mike42 avatar Feb 10 '20 08:02 mike42

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

PratikBodawala avatar Feb 10 '20 10:02 PratikBodawala