url encode latin-1 characters

L

Lurker

I want send latin-1 string to web server by url parameter

urllib.quote return just symbol code with preceeding percent for every
non-ascii character:
#>ustr = 'Ü'
#>urllib.quote(ustr)
'%9A'

but this seems to be wrong because server response contains my
parameter and it differ from original (for example 'Ü' became '[')
 
J

John Machin

Lurker said:
I want send latin-1 string to web server by url parameter

urllib.quote return just symbol code with preceeding percent for every
non-ascii character:
#>ustr = 'Ü'
#>urllib.quote(ustr)
'%9A'

The latin1 encoding for U-with-umlaut is 0xDC.
The cp850 encoding for the same is 0x9A.
I deduce that you typed the above in a DOS command window on a Windows
box.
Fire up IDLE and try the same thing again.
but this seems to be wrong because server response contains my
parameter and it differ from original (for example 'Ü' became '[')

You told it (maybe) that you were sending in latin1, then gave it 0x9A
which in latin1 is a control character (SCI, single character
introducer) and it gave you back a '[' ... garbage in, garbage out,
perhaps?

How about showing us (a) a snippet of the code you actually executed
(b) the repr() of what was returned -- *NOT* a copy/paste from the
screen; as shown above, a picture of U with two dots above it is not
reliable information.

Cheers,
John
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top