question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chinese cp936 support

See original GitHub issue

Bug description

Actually this is not a bug, but a question. I am looking to use this lib to print Chinese characters (cp936), has no luck to succeed yet. The platform is beaglebone.

Any help is appreciated.

Steps to reproduce

– I am adding a new printer in the profile:


  RD-DH32:
  name: RD-DH32
  vendor: Rongda Beijing
  inherits: default
  notes: >
      RD-DH32 http://www.rd-cn.com/uploadfile/2015/1029/20151029014450556.pdf.
  features:
    barcodeB: false
    bitImageColumn: true
    bitImageRaster: true
    graphics: false
    qrCode: false
    pdf417Code: false
    starCommands: True
  codePages:
    0: CP936

– And provide the magic_encode_args in the printer arguments, such as:

code:: python

magic_encode_args = dict(encoding='cp936')
p = Dummy(profile='RD-DH32', magic_encode_args=magic_encode_args)
p.text(u"荣")  # 打印文字
out = p.output
for i in out:
    print "0x{0:02x}".format(ord(i))

Looks like I got things incorrect: 0x3f

I am considering the method is incorrect. Any hints will be appreciated.

Device info

Printer: Manufacturer Model XVI

python-escpos version: 0.0.0 2.2.1

python version: 0.0 2.7

operating system: Ubuntu

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
azpdlcommented, Mar 25, 2017
#coding=utf8

from escpos.printer import Serial
""" Seiko Epson Corp. Receipt Printer M129 Definitions (EPSON TM-T88IV) """
Epson = Serial('COM6')
Epson.codepage="gb2312"   #设置解码的类型
# Print text

Epson.text(u"你好\n"
           u"   测试你好\n"
           u"   空格\n"
           u"              飞\n"
           u"")

@2q1w2007 只需要设置一下codepage就可以了。


win10 python2.7 epson TM-88IV

1reaction
hengyingcommented, Mar 7, 2021

@NullYing Hi, thanks for the solution, it’s a stable solution. I’ve use it in my program.

I can print with chinese characters in master branch, but I can’t find a better way

p = Dummy()
p._raw("中文\n".encode('GB18030'))
p.cut()

I installed a new version of escpos today:

print(escpos.__version__)
3.0a8

According to you try and some source code reading, I found I could print Chinese characters correctly by just this line:

printer._raw("中文\n".encode('GB18030'))

Even don’t need to set the codepage.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Code page 936 (Microsoft Windows) - Wikipedia
Windows Code page 936 is Microsoft's character encoding for simplified Chinese, one of the four DBCSs for East Asian languages. Originally, Windows-936 ...
Read more >
Adding Code page 936 for proper display of Chinese characters
The most common is the Microsoft CP936. This corresponds to the IANA “GBK” font. To properly display simplified Chinese characters in eFORMz ...
Read more >
MIME MESSAGES WITH CHARACTER ENCODING CP936 ...
Then the Chinese Characters in the mail body display well. Problem summary. LCU supports CP936, but the caller function does not use the...
Read more >
What is the differnence between gbk and cp936 - Stack Overflow
My locale encoding is 'gbk' in other programming tools as I am a simplified Chinese user. But in Python ...
Read more >
Retrieving multi-byte Chinese characters with ASE OLE DB ...
When using ASE OLE DB Provider with an ASE configured for charset cp936 (Chinese) the retrieval of chinese characters returns them in garbled...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found