By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,180 Members | 1,133 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,180 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Oct 3 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
In message <ma**************************************@python.o rg>, 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?
Oct 4 '08 #2

P: n/a
On 104, 5ʱ38, "Valery Khamenya" <khame....@gmail.comwrote:
Hi all

things like urllib.quote(u"ڧӧ Mller ") 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("ڧӧ Mller ")
Oct 5 '08 #3

P: n/a
Hello,
things like urllib.quote(u"ڧӧ Mller ") 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"ڧӧ Mller "
print urllib.quote(n.encode("utf-8")) -%D0%BF%D0%B8%D0%B2%D0%BE%20M
%C3%BCller

HTH,
--
Miki <mi*********@gmail.com>
http://pythonwise.blogspot.com
Oct 5 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.