gurke
Posts: 11
Joined: Thu Sep 03, 2015 7:49 pm

charset thermoprinter "umlaut" like ä, ß, etc

Fri Apr 28, 2017 9:54 am

Hi,
I hope this question isn't too stupid, but I have no idea where to find an answer.
I have a thermal printer (https://shop.pimoroni.com/products/mini-thermal-printer) connected to my pi and it's doing fine.
BUT: how do I print german "Umlaute" like ä, ß, etc. ?
Can I just change the utf-coding?

Thanks for your help!

Code: Select all

#!/usr/bin/env python
# coding: utf-8
import printer, textwrap, sys

p=printer.ThermalPrinter(serialport="/dev/ttyAMA0")
unwrapped_text = sys.stdin.read()
wrapped_text = textwrap.fill(unwrapped_text, 32)
p.print_text(wrapped_text)
p.linefeed()
p.linefeed()
p.linefeed()

User avatar
paddyg
Posts: 2541
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: charset thermoprinter "umlaut" like ä, ß, etc

Fri Apr 28, 2017 10:37 am

It looks to have the functionality to change the characterset in the datasheet and the adafruit/Python-Thermal-Printer on github
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

ghp
Posts: 1498
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: charset thermoprinter "umlaut" like ä, ß, etc

Fri Apr 28, 2017 7:52 pm

Hello,
in addition to paddyg's comment, it looks as if this printer supports single byte char sets only. Perhaps better to start with python3 to handle all data in utf and before sending to the device the encoding should be adjusted.
Hope this helps,
Gerhard

Return to “Python”