S
Svennglenn
I'm working on a program that is supposed to save
different information to text files.
Because the program is in swedish i have to use
unicode text for ÅÄÖ letters.
When I run the following testscript I get an error message.
# -*- coding: cp1252 -*-
titel = "åäö"
titel = unicode(titel)
print "Titel type", type(titel)
fil = open("testfil.txt", "w")
fil.write(titel)
fil.close()
Traceback (most recent call last):
File "D:\Documents and
Settings\Daniel\Desktop\Programmering\aaotest\aaotest2\aaotest2.pyw",
line 5, in ?
titel = unicode(titel)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0:
ordinal not in range(128)
I need to have the titel variable in unicode format because when I
write
åäö in a entry box in Tkinkter it makes the value to a unicode
format
automaticly.
Are there anyone who knows an easy way to save this unicode format text
to a file?
different information to text files.
Because the program is in swedish i have to use
unicode text for ÅÄÖ letters.
When I run the following testscript I get an error message.
# -*- coding: cp1252 -*-
titel = "åäö"
titel = unicode(titel)
print "Titel type", type(titel)
fil = open("testfil.txt", "w")
fil.write(titel)
fil.close()
Traceback (most recent call last):
File "D:\Documents and
Settings\Daniel\Desktop\Programmering\aaotest\aaotest2\aaotest2.pyw",
line 5, in ?
titel = unicode(titel)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0:
ordinal not in range(128)
I need to have the titel variable in unicode format because when I
write
åäö in a entry box in Tkinkter it makes the value to a unicode
format
automaticly.
Are there anyone who knows an easy way to save this unicode format text
to a file?