如何使用 python-escpos 打印希腊字符
第 1 部分
我目前正在尝试让我的打印机为我的餐厅订购系统正确输出希腊语而不是 GreekLish。
我正在使用 python-escpos。
- 我的代码如下所示。
from escpos.printer import Usb
p = Usb(0x471, 0x55, 0, 0x82, 0x2)
p.charcode(code='Greek')
p.text('Καλημέρα \n')
p.cut()
p.close()
- 我的输出如下所示。
我的字符串输入有问题吗?我应该对其进行编码吗?
此外,图书馆目前在商店内运作。问题是而不是打印,例如,Kαλnμερα
,我必须打印Kalimera
,希腊语。我需要它看起来更专业。
谢谢
第 2 部分
添加了编码魔法仍然没有...
from escpos.printer import Usb
from escpos.exceptions import USBNotFoundError
from escpos.magicencode import MagicEncode, Encoder
import requests
resp = requests.get('https://raw.githubusercontent.com/receipt-print-hq/escpos-printer-db/3612db407d02a08acd93a1540f2b4823be3f020e/dist/capabilities.json')
js = resp.json()
encodings = list(js['encodings'].keys())
for encoding in encodings:
print(encoding)
try:
p = Usb(idVendor=0x471, idProduct= 0x55,in_ep=0x82, out_ep=0x02)
p.magic.force_encoding(encoding)
p.text(encoding)
p.text('ΚΑΛΗΜΕΡΑ \n')
p.cut()
p.close()
except USBNotFoundError:
print('printer not connected or on')
except Exception as e:
print(e)
我的输出看起来像这样...
对我来说没有希腊语早安... 我相信我已经非常接近了。还有其他建议吗?
第 3 部分
我们在第二个 _raw
函数中输入一些命令怎么样?
p = Usb(idVendor=0x471, idProduct= 0x55,in_ep=0x82, out_ep=0x02)
ESC = b'\x1b'
p._raw(ESC + b'\x74\x07') # page 28-29 printer manual
p._raw( add something...) # need to print Καλημερα
p.cut()
p.close()
帮助
打印机型号 Alpha TP-80H
打印机还附带一张自检页。
PART 1
I am currently trying to get my printer to properly output Greek and not GreekLish for my restaurant ordering system.
I am using python-escpos.
- My code looks like this.
from escpos.printer import Usb
p = Usb(0x471, 0x55, 0, 0x82, 0x2)
p.charcode(code='Greek')
p.text('Καλημέρα \n')
p.cut()
p.close()
- My output looks like this.
Is there an issue with my string input? Am I supposed to encode it?
Also, The library works currently in shops. The issue is instead of printing, for example, Καλημερα
I have to print Kalimera
, greeklish. I need it to look more professional.
Thank you
PART 2
Added the encoding magic still nothing...
from escpos.printer import Usb
from escpos.exceptions import USBNotFoundError
from escpos.magicencode import MagicEncode, Encoder
import requests
resp = requests.get('https://raw.githubusercontent.com/receipt-print-hq/escpos-printer-db/3612db407d02a08acd93a1540f2b4823be3f020e/dist/capabilities.json')
js = resp.json()
encodings = list(js['encodings'].keys())
for encoding in encodings:
print(encoding)
try:
p = Usb(idVendor=0x471, idProduct= 0x55,in_ep=0x82, out_ep=0x02)
p.magic.force_encoding(encoding)
p.text(encoding)
p.text('ΚΑΛΗΜΕΡΑ \n')
p.cut()
p.close()
except USBNotFoundError:
print('printer not connected or on')
except Exception as e:
print(e)
My output looks like this...
No Greek Goodmorning for me...
I believe I am very close. Any other suggestions?
PART 3
how about we enter some command in the second _raw
function?
p = Usb(idVendor=0x471, idProduct= 0x55,in_ep=0x82, out_ep=0x02)
ESC = b'\x1b'
p._raw(ESC + b'\x74\x07') # page 28-29 printer manual
p._raw( add something...) # need to print Καλημερα
p.cut()
p.close()
HELPFULL
printer model Alpha TP-80H
the printer also came with a self-test page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用字符代码和代码页
以下代码适用于我的 NT-5890K 打印机
Use the charcode and the codepage
The following code works with my NT-5890K printer