Magic encoding broken on second call of the same script
See original GitHub issueBug description
Automatic encoding does not work on second call of the same script
Steps to reproduce
Start the provided script twice. Character encoding is broken on the second call. Here is the script: The Euro and German umlaut symbols are working fine on first call after device reset but are broken on subsequent calls of the script.
Unfortunately it will sometimes need a few more tries before it will get broken.
from escpos.printer import Usb
p = Usb(0x0416, 0x5011,0, profile="POS-5890")
p.text("\n")
p.set(align=u'left', custom_size=True, width=2, height=2, font=1)
p.text("SUMME €10,47\n\n")
p.text("Bar: €15,00\n")
p.text("Rückgeld: €4,53\n")
p.cut()
Device info
Printer: Excelcan ZJ-5890K python-escpos version: 3.0a3 python version: 3.5.3 (distro version) operating system: Debian 9.x
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Fixing broken UTF-8 encoding - php - Stack Overflow
I used this myself on a feed with mixed encodings in the same string. Usage: $utf8_string = Encoding::toUTF8($mixed_string); $latin1_string = ...
Read more >This article is about encodings and character sets ... - kunststube
An encoding is the set of rules with which to convert something from one representation to another. Other terms which deserve clarification in ......
Read more >Yet Another Python Encoding Tutorial - | notebook.community
This notebook shows how to manage text encodings with Python. It is mostly based in the Unicode HOWTO, and the codecs library module...
Read more >Files & Character Encoding — Introduction to Cultural ...
The document is not broken…there's no magic you need to perform, you simply need to select the right encoding to display the document....
Read more >UTF-8: The Secret of Character Encoding - HTML Purifier
Finding the real encoding; Finding the embedded encoding; Fixing the encoding ... in the same encoding as the page, or set it to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can pass on arguments that control magic_encode when you are creating the instance of your printer. Issue something like
Usb(0x0416, 0x5011,0, profile="POS-5890", magic_encode_args=PUT THEM HERE)
You can put there a dictionary with the arguments for magic_encode. The class is described here.
If you set
encoding
to a suitable codepage anddisabled
to True, then it will print just in this codepage. The rest (unicode-input, automatic encoding into the set codepage) remains unchanged.You can also call
p.magic.force_encoding(encoding)
for the same result.encoding
is the name of your codepage. In this case, please try “CP858”.Hm looks like some USB bus timing problem and or broken printer firmware. Files generated this way by python escpos are identical. Printing a file written using sys.stdout.buffer.write(p.output) using “cat file >/dev/usb/lp0” is producing the same Euro sign errors. Does anybody have a ZJ-5890K device where this code works? I wonder if there is a firmware update for the device.