I want to write an application in Python 3 that should print letters: æ, å, ø. When using the Python IDLE, everything runs great, but I need this application to work in the terminal (Windows 7). Python shows following letters: ł, ę, ą, ś, ć, ź, ż, and ó as it should both in IDLE and the console. But my app needs to work with all these letters. I get this error:
UnicodeEncodeError: 'charmap' codec can't encode character '\xe5' in position 0: cha
racter maps to <undefined>
\xe5 should be å. What should I do to make it work?
import sys, os, msvcrt
import tavla
def make():
os.system("cls")
get_verb = input("Angje verbet (separer med komma): ")
polish = input("Angje det polske ordet: ")
verb = get_verb.split(",")
try:
tavla.tavla(verb[0],verb[1],verb[2],verb[3], polish)
print ("Trykk på ein knapp for å fortsetta...")
msvcrt.getch()
except IndexError:
sys.exit(2)
if __name__ == '__main__':
make()
The "tavla" script causes no problems:
def tavla(ubund_sing="et hus", bund_sing="huset", ubund_pl="hus", bund_pl="husene", polsk="dom"):
a = "\t|{0}|\t|{1}|\t\t|{2}|\t\t|{3}|".format(ubund_sing, bund_sing, ubund_pl, bund_pl)
print(a)
print("\n\t\t\t\t{0}".format(polsk))
The problem is this line:
print ("Trykk på ein knapp for å fortsetta...")
because it uses the letter "å". Intended, tavla should show all the letters: æ, å, ø, é ł, ę, ą, ś, ć, ź, ż, ó
# -*- coding: utf-8 -*-
doesn't change anything at all. Still the same.