Stuck with urllib.quote and Unicode/UTF-8

Chris Rebert clp2 at rebertia.com
Sat May 7 10:14:55 EDT 2011


On Sat, May 7, 2011 at 5:35 AM, Marian Steinbach <marian at sendung.de> wrote:
> An addition/correction:
>
> It seems as if my input variable address is not Unicode. This is what
> I get for print [address]:
>
> ['K\xf6ln, Nordrhein-Westfalen']
>
> Isn't this utf-8 encoding?

Nope, it's Latin-1 (or similar, e.g. Windows-1252):
Python 2.7.1 (r271:86832, Dec  5 2010, 00:12:20)
>>> x = u"Köln"
>>> x.encode('utf_8')
'K\xc3\xb6ln'
>>> x.encode('latin_1')
'K\xf6ln'
>>>

Cheers,
Chris
--
http://rebertia.com



More information about the Python-list mailing list