Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

Stephan Diehl stephan.diehl at gmx.net
Tue Jan 4 09:17:04 EST 2005


On Tue, 04 Jan 2005 05:43:32 -0800, michele.simionato wrote:

> Holger:
> 
>> FWIW, i added the recipe back to the online cookbook. It's not
> perfectly
>> formatted but still useful, i hope.
> 
>>   http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/361742
> 
> Uhm... on my system I get:
> 
>>>> german_ae = unicode('\xc3\xa4', 'utf8')
>>>> print german_ae # dunno if it will appear right on Google groups
> ä
> 
>>>> german_ae.decode('latin1')
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in
> position 0: ordinal not in range(128)
> ?? What's wrong?

I'd rather use german_ae.encode('latin1')
                         ^^^^^^

which returns '\xe4'.
> 
>         Michele Simionato




More information about the Python-list mailing list