Hi,
In the specs for the Mini Thermal Receipt Printer it shows: "Character Set: ASCII,GB2312-80(Chinese)"
I'm unsure how I would go about using the GB2312-80 / chinese character set?
The manual doesn't mention it as far as I can see.
Of course just printer.write("按"); isn't doing it, has anyone managed to print chinese characters before or have any ideas what I could try?
Grateful for any responses.
How can I get Chinese Characters on the Mini Thermal Printer
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- ArtificialFoxx
- Posts: 3
- Joined: Mon Oct 13, 2014 5:20 pm
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: How can I get Chinese Characters on the Mini Thermal Pri
Not sure why the product page says that. I don't believe that the thermal printer does comes with a Chinese character set. But I'll double-check.
- adafruit2
- Posts: 22200
- Joined: Fri Mar 11, 2005 7:36 pm
Re: How can I get Chinese Characters on the Mini Thermal Pri
we just used the spec sheet for the specs - we haven't actually tried anything other than english - however it loks like you can set languages and code pages...may want to check out page 16 of the user manual for "ESC t n" and "ESC R n" commands - let us know if you find out anything!ArtificialFoxx wrote:Hi,
In the specs for the Mini Thermal Receipt Printer it shows: "Character Set: ASCII,GB2312-80(Chinese)"
I'm unsure how I would go about using the GB2312-80 / chinese character set?
The manual doesn't mention it as far as I can see.
Of course just printer.write("按"); isn't doing it, has anyone managed to print chinese characters before or have any ideas what I could try?
Grateful for any responses.
- ArtificialFoxx
- Posts: 3
- Joined: Mon Oct 13, 2014 5:20 pm
Re: How can I get Chinese Characters on the Mini Thermal Pri
Thanks for the responses.
The command below that looks interesting but it only mentiones the 437 and 850 character sets.
After doing some more searching around for general information about character sets I found the following:
The site provides this table: http://www.khngai.com/chinese/charmap/tblgb.php?page=0
Presumably A4C0 would be a chinese character etc.
Could that be done like this: printer.write(0xa4c0); ? - I'll give this a go when I next have access to my printer!
Unfortunately this seems to only re-map some of the exisiting characters to few different hex codes rather than provide a different font set entirely.adafruit2 wrote: we just used the spec sheet for the specs - we haven't actually tried anything other than english - however it loks like you can set languages and code pages...may want to check out page 16 of the user manual for "ESC t n" and "ESC R n" commands - let us know if you find out anything!
The command below that looks interesting but it only mentiones the 437 and 850 character sets.
After doing some more searching around for general information about character sets I found the following:
Perhaps that means that you can access them without changing the character set?Every Chinese character is represeneted by a two byte code. The MSB of both the first and second bytes are set. Thus, they can be easily identified from documents that contain both GB characters and regular ASCII characters.
The site provides this table: http://www.khngai.com/chinese/charmap/tblgb.php?page=0
Presumably A4C0 would be a chinese character etc.
Could that be done like this: printer.write(0xa4c0); ? - I'll give this a go when I next have access to my printer!
- brandon_r87
- Posts: 1
- Joined: Fri Feb 19, 2016 3:56 am
Re: How can I get Chinese Characters on the Mini Thermal Pri
Did you ever get this figured out? I'm working on this too. I've been researching for the past hour. From looking at the manual https://www.adafruit.com/datasheets/CSN ... Manual.pdf, page 29 refers to changing the printer to Chinese using ESC 9 n where n is your encoding (0: GBK, 1: UTF-8, or 3: Big8). I would assume afterwards you change it back to your own character code table (ESC t 0 is default). I wrote the following code in the Adafruit_Thermal.py file:
I then did something like this:
Unfortunately, I get this still doesn't work. I always get an error like this, even though I've tried playing around with encodings:
Hopefully this gets closer or someone will see how to fix it.
Code: Select all
def chineseOn(self):
self.writeBytes(27, 57, 1) #ESC 9 1
def chineseOff(self):
self.writeBytes(27, 116, 0) #ESC t 0
Code: Select all
#!/usr/bin/python
# -*- coding: utf-8 -*-
from Adafruit_Thermal import *
printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
a = u"你好世界" # "Hello World"
printer.chineseOn()
printer.println(a)
printer.chineseOff()
Code: Select all
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: How can I get Chinese Characters on the Mini Thermal Pri
So, this is a python error from using println. I don't know a lot about python, but I think you want to be using a binary output method, not an ascii output method. Is there a "write" method that outputs a binary buffer?
- ArtificialFoxx
- Posts: 3
- Joined: Mon Oct 13, 2014 5:20 pm
Re: How can I get Chinese Characters on the Mini Thermal Pri
Unfortunately I didn't make any further progress on this. I didn't get around to trying to change modes.brandon_r87 wrote:Did you ever get this figured out?
Best of luck, if you do get it working let us know - it seems a few people are trying to do this.
- dhalbert
- Posts: 401
- Joined: Tue Feb 17, 2015 6:18 pm
Re: How can I get Chinese Characters on the Mini Thermal Pri
Dealing with unicode in Python 2 is somewhat fiddly. I did some experimentation. I don't have a printer to try this on, but try this code:
You may also be able to do this to get the newline included:
Code: Select all
a = u"你好世界" # "Hello World"
printer.chineseOn()
printer.write(a.encode("utf-8"))
printer.write("\n")
printer.chineseOff()
Code: Select all
printer.println(a.encode("utf-8"))
- Wang_shinchih
- Posts: 1
- Joined: Mon Jun 10, 2019 2:10 am
Re: How can I get Chinese Characters on the Mini Thermal Pri
How can I print Chinese with Arduino UNO
Please be positive and constructive with your questions and comments.