-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chinese ESCPOS Support #285
Comments
Hi @tresf, A quick search showed that first you might need a Chinese capable ESCPOS which contains a set of commands for Chinese only: e.g. |
@liushuyu thanks. There's a printer on order from Alibaba. We will try this as soon as it arrives. |
The printer arrived. I'm updating this ticket with some emails to the printer manufacturer. We do not yet have a successful print. Here is the email conversation. Some items have been paraphrased for clarity.
...
|
It's definitely not correct Chinese. The characters were from extension area (rarely used character), and you can see the length of original text is half the length of the printed text. |
And do note your test text is in Traditional Chinese, although it's also supported in Here's a example of a short segment of Simplified Chinese:
(This sentence is in Simplified Chinese) |
Hi, I think I found something you may be interested:
And when you encode it with UTF-8: In [16]: test = '''艾德蒙 AOC E2450SWH 23.6吋\n
...: LED液晶寬螢幕特價$ 19900'''
In [17]: test.encode('utf-8')
Out[17]: b'\xe8\x89\xbe\xe5\xbe\xb7\xe8\x92\x99 AOC E2450SWH 23.6\xe5\x90\x8b\n\n LED\xe6\xb6\xb2\xe6\x99\xb6\xe5\xaf\xac\xe8\x9e\xa2\xe5\xb9\x95\xe7\x89\xb9\xe5\x83\xb9$ 19900' Then decode the encoded sequence using GB18030 (which was encoded in UTF-8), Python will give a decode error since its codec is very strict and comply with the standard. In [18]: b'\xe8\x89\xbe\xe5\xbe\xb7\xe8\x92'.decode('gb18030')
Out[18]: '鑹惧痉钂' The output is just what was printed out (first 4 characters). And I think what happened was |
@liushuyu I had assumed the problem was improper Java decoding but I'm awaiting some more information from Lite's testing. Thank you kindly for the research. It's exactly what I was suspecting when I saw his printout. :) |
Thanks for your response, and I think that's "improper Java encoding" ? Since it was the printer that did the decode job :-) |
For the reference:
|
@liushuyu perhaps, but I don't think so. Encoding is two-part. 1. Java, 2. Printer. Here's my official write-up on it. https://qz.io/wiki/Raw-Encoding#background Chinese is not unique. Java must convert UTF-8 to |
Though using 'encoding: 'GB18030'" was not successful, I was successful using 'encoding: 'GBK'' The printer is Fukun POS80 First, I tried the Traditional Chinese sample: function printESCPOS() {
var config = qz.configs.create("Fukun", {encoding: 'GBK'}); //Toggle GBK in Java (GB18030 did not work)
var printData = [
'\x1B' + '\x40',
//'\x1B' + '\x74' + '\x0E',
'艾德蒙 AOC E2450SWH 23.6吋\n',
' LED液晶寬螢幕特價$ 19900',
'\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A' + `'\x0A',`
'\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A',
'\x1B' + '\x69' // cut paper
]; I then tried the Simplified Chinese example provided by @liushuyu (thank you!): function printESCPOS() {
var config = qz.configs.create("Fukun", {encoding: 'GBK'}); //Toggle GBK in Java (GB18030 did not work)
var printData = [
'\x1B' + '\x40',
//'\x1B' + '\x74' + '\x0E',
'这句话是简体中文',
'\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A',
'\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A',
'\x1B' + '\x69' // cut paper
]; And results were again correct. My last question for this test: If this printer were capable of printing GBK, but GBK was not the current codepage for the printer, how, using ESC/POS, would a user change the codepage to GBK? I will test using Enter/Exit Hanzi mode as described by @liushuyu above. |
As you may have known, GBK is a compatible subset of GB18030 codec, or more precisely, GB18030 (a standard published in 2006) is an extension to the original GBK (only a recommendation published in 1995). And GB18030 added partial Japanese and Korean support (Kanji Extension A area) but still backward compatible, that's why you can print out the text correctly using GBK encoding even though the printer's current codepage was GB18030. EDIT:
|
Documented here: https://qz.io/wiki/Raw-Encoding#escpos-simplified-chinese. Closing. |
Just a status update, Lite got Traditional Chinese printing on Epson TM88V-631 which was pre-configured from Epson with "Big5" support. At the time of writing this, the US models of TM88V are incapable of printing "Big5" however the Chinese models can. Furthermore, the successor -- the TM88VI can also with firmware that can be loaded by any official Epson reseller. |
We're adding support for more character sets in ESCPOS by testing -- and documenting various languages but we don't know the status of Chinese.
This is a placeholder to track the progress with printing chinese.
Keywords: Chinese, printer, epson, programming, 中国打印机爱普生编程
Languages already supported: https://qz.io/wiki/Raw-Encoding#escpos
The text was updated successfully, but these errors were encountered: