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

  • Thread starter Valery Khamenya
  • Start date
V

Valery Khamenya

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
 
L

Lawrence D'Oliveiro

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?
 
R

Rou Bao

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

don't unicode the str, just urllib.quote("§á§Ú§Ó§à M¨¹ller ")
 
M

Miki

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top