Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Problem: neither urllib2.quote nor urllib.quote encode the unicodestrings arguments

Reply
Thread Tools

Problem: neither urllib2.quote nor urllib.quote encode the unicodestrings arguments

 
 
Valery Khamenya
Guest
Posts: n/a
 
      10-03-2008
Hi all

things like urllib.quote(u"пиво Müller ") fail with error message:
<type 'exceptions.KeyError'>: u'\u043f'

Similarly with urllib2.

Anyone got a hint?? I need it to form the URI containing non-ascii chars.
thanks in advance,
best regards
--
Valery
 
Reply With Quote
 
 
 
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      10-04-2008
In message <mailman.1981.1223069889.3487.python->, Valery
Khamenya wrote:

> things like urllib.quote(u"пиво Müller ") fail with error message:
> <type 'exceptions.KeyError'>: u'\u043f'


Did you try encoding it as UTF-8 first?
 
Reply With Quote
 
 
 
 
Rou Bao
Guest
Posts: n/a
 
      10-05-2008
On 10ÔÂ4ÈÕ, ÉÏÎç5ʱ38·Ö, "Valery Khamenya" <khame....@gmail.com> wrote:
> Hi all
>
> things like urllib.quote(u"§á§Ú§Ó§à M¨¹ller ") fail with error message:
> <type 'exceptions.KeyError'>: u'\u043f'
>
> Similarly with urllib2.
>
> Anyone got a hint?? I need it to form the URI containing non-ascii chars.
> thanks in advance,
> best regards
> --
> Valery


don't unicode the str, just urllib.quote("§á§Ú§Ó§à M¨¹ller ")
 
Reply With Quote
 
Miki
Guest
Posts: n/a
 
      10-05-2008
Hello,

> things like urllib.quote(u"§á§Ú§Ó§à M¨¹ller ") fail with error message:
> <type 'exceptions.KeyError'>: u'\u043f'
>
> Similarly with urllib2.
>
> Anyone got a hint?? I need it to form the URI containing non-ascii chars

..

n = u"§á§Ú§Ó§à M¨¹ller "
print urllib.quote(n.encode("utf-8")) -> %D0%BF%D0%B8%D0%B2%D0%BE%20M
%C3%BCller

HTH,
--
Miki <>
http://pythonwise.blogspot.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Problem: neither urllib2.quote nor urllib.quote encode theunicode strings arguments Jerry Hill Python 0 10-03-2008 11:37 PM
XPath Problem: Select all childnodes, that names are neither "name1" nor "name2" adurth@cs.tu-berlin.de XML 7 02-26-2007 02:03 PM
A text which neither gets very narrow nor disappears Luigi Donatello Asero HTML 21 01-06-2006 11:32 PM
c is a low-level language or neither low level nor high level language pabbu C Programming 8 11-07-2005 03:05 PM
Neither Han nor Greedo will shoot first Mark W DVD Video 6 12-05-2003 07:45 AM



Advertisments