Reading special Danish letters in Python

Martin Hvidberg Martin at Hvidberg.net
Sun Dec 19 16:41:58 EST 2010


Dear list

I have to read some data from an ASCII text file, filter it, and then 
export it to a .dbf file. Basically a straight forward task...
My problem is that the input files contains some special national 
(Danish) characters, and it appears that I have to do something special 
to handle these in Python.
The Danish language contains three letters not in the English alphabet: 
æ, ø and å.
E.g. the Danish city name 'SOLRØD' is red by Python as 'SOLR\xc3\x98D'
The three letters, in lower and upper case, seems to get translated as 
follow:

æ = \xc3\xa6
ø = \xc3\xb8
å = \xc3\xa5
Æ = \xc3\x86
Ø = \xc3\x98
Å = \xc3\x85

Question:
What is this, how do I get my Danish letters back?

Best Regards
Martin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101219/3bc22b50/attachment.html>


More information about the Python-list mailing list