string title() method does not work on Danish characters

Max M maxm at mxm.dk
Thu Feb 28 10:40:25 EST 2002


Jason Orendorff wrote:

> First: Unicode strings will solve your problem.

Hi Jason

Thanks for the suggestion, but it does not solve my problem. I am 
pulling the data from an older MS SQL server that returns standard ascii.

The Danish characters in question (æøåÆØÅ) is defined in the 128-255 
range, so when I try to do either .unicode() or .decode() i get "ordinal 
not in range(128)"

Se my misserable attempts below :-(

I will hit "The Essential Reference" again and see what I can dig up.

regards Max M



 >>> name.encode('latin-1')
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
UnicodeError: ASCII decoding error: ordinal not in range(128)

 >>> name.encode('utf-8')
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
UnicodeError: ASCII decoding error: ordinal not in range(128)

 >>> name.encode('unicode-escape')
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
UnicodeError: ASCII decoding error: ordinal not in range(128)

 >>> name.encode('unicode', 'replace')
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
UnicodeError: ASCII decoding error: ordinal not in range(128)

 >>> name.encode('utf-8', 'replace')
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
UnicodeError: ASCII decoding error: ordinal not in range(128)

 >>> name.encode('latin-1', 'ignore')
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
UnicodeError: ASCII decoding error: ordinal not in range(128)

 >>> name.encode('latin-1', 'replace')
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
UnicodeError: ASCII decoding error: ordinal not in range(128)




More information about the Python-list mailing list