I'm trying to print nordic/swedish characters on the thermal printer. I have tried unicode and different of "replacing" solutions.
I have a python script that reads an rss news feed with swedish letters (åäö). This is a similar problem (http://forums.adafruit.com/viewtopic.ph ... BP#p249535) but I don't know how to implement.
How should I solve this?
thermal printer: nordic characters error
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: thermal printer: nordic characters error
Have you looked at the extended character tables at the end of the User Manual? All of those characters are in both versions of the character ROM. You just need to map to the right codes.
For instance, å is 0x86, ä is 0x84, and ö is 0x94.
There are upper-case versions as well.
For instance, å is 0x86, ä is 0x84, and ö is 0x94.
There are upper-case versions as well.
-
- Posts: 10
- Joined: Mon Jan 13, 2014 12:57 pm
Re: thermal printer: nordic characters error
I did make it work now! Thanks, some regex replacement leftadafruit_support_rick wrote:
For instance, å is 0x86, ä is 0x84, and ö is 0x94.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: thermal printer: nordic characters error
Can you share what you had to do to make it work?
-
- Posts: 3
- Joined: Fri Jul 04, 2014 9:56 am
Re: thermal printer: nordic characters error
If there's still people out there who are fighting with the same issue (using python), here's the solution.
You create a dictionary with your special characters and look up their replacement chars in the character code table that you get, when you connect the printer to a power source while pressing the button on the printer.
Here's my dictionary and the function that takes care of the char replacement in an input string.
You create a dictionary with your special characters and look up their replacement chars in the character code table that you get, when you connect the printer to a power source while pressing the button on the printer.
Here's my dictionary and the function that takes care of the char replacement in an input string.
Code: Select all
specialChars = {'Ä':'\x8E', 'ä':'\x84', 'Ö':'\x99', 'ö':'\x94', 'Ü':'\x9A', 'ü':'\x81', 'ß':'\xE1'}
def replace_all(text, dic):
for i, j in dic.iteritems():
text = text.replace(i, j)
return text
Please be positive and constructive with your questions and comments.