urllib.quote and unicode

Tim Roberts timr at probo.com
Fri Dec 6 02:34:06 EST 2002


Kelly <kkranabetter at yahoo.com> wrote:

>Urllib's quoting of Unicode characters doesn't seem to work right in Python 
>2.2.1:
>
>>>> urllib.quote(unichr(8225))    # double dagger
>'%2021'
>>>> urllib.unquote("%2021")
>' 21'

urllib.quote was designed for encoding URLs.  URLs have to be ISO-8859-1,
so they cannot include Unicode characters.

>I couldn't find anything very useful on the web about quoting Unicode but 
>Microsoft IIS does understand Unicode characters when quoted like: 
>"%u2021".

That's a Microsoft extension.  Feel free to submit a patch if you wish.
--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list