thermal printer: nordic characters error

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
auty
 
Posts: 10
Joined: Mon Jan 13, 2014 12:57 pm

thermal printer: nordic characters error

Post by auty »

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?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: thermal printer: nordic characters error

Post by adafruit_support_rick »

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.

auty
 
Posts: 10
Joined: Mon Jan 13, 2014 12:57 pm

Re: thermal printer: nordic characters error

Post by auty »

adafruit_support_rick wrote:
For instance, å is 0x86, ä is 0x84, and ö is 0x94.
I did make it work now! Thanks, some regex replacement left

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: thermal printer: nordic characters error

Post by adafruit_support_rick »

Can you share what you had to do to make it work?

frosenberger
 
Posts: 3
Joined: Fri Jul 04, 2014 9:56 am

Re: thermal printer: nordic characters error

Post by frosenberger »

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.

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

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”