Message2032
Currently urllib.quote does not handle
Unicode strings. urllib should be able to handle those.
According to http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.1
what is required is:
1. Represent each character in UTF-8 (see [RFC2279]) as
one or more bytes.
2. Escape these bytes with the URI escaping mechanism
(i.e., by converting each byte to %HH, where HH is the
hexadecimal notation of the byte value).
urllib.quote already does 2. For Unicode strings it should
do 1. too.
This chances the meaning of urllib.quote slightly, now an
8bit string would be interpreted as being utf8 encoded. To
fix this an 8bit string should be transcoded from the default encoding to utf8 first, i.e. what should be
inserted at the beginning of quote is:
if type(s) == types.StringType:
s = unicode(s,sys.getdefaultencoding())
s = s.encode("utf8")
|
|
Date |
User |
Action |
Args |
2007-08-23 13:51:42 | admin | link | issue216716 messages |
2007-08-23 13:51:42 | admin | create | |
|