Encoding

L

Lad

I have a script that uses utf-8 encoding. Now I would like to send some
data to an application ( on another server) that uses 1250 encoding.
How can I tell the server that the coming data will be in utf-8 code?
I tried this
params='some data'
h = httplib.HTTP(self.host)
h.putheader("Content-type", "multipart/form-data;
boundary=---------------------------7d329422844")
h.putheader("Content-length", "%d" % len(params))
h.putheader("Accept-Language", "us-en")
h.putheader('Accept', 'image/gif, image/x-xbitmap, image/jpeg,
image/pjpeg, */*')
h.putheader('User-Agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows
NT 5.1)')
h.putheader('Host', 'server')
h.endheaders()
......
.....

but it doesn't work. The data are not encoded properly
Thanks for help
L.B.
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Lad said:
I have a script that uses utf-8 encoding. Now I would like to send some
data to an application ( on another server) that uses 1250 encoding.
How can I tell the server that the coming data will be in utf-8 code?

You can't, normally. In theory, you should put

Content-type: text/plain;charset=utf-8

into the individual *part*. However, many implementations will ignore
the charset= argument on a part.

Instead, the convention is that the data must be transmitted in the
encoding of the *HTML page* which contained the form you are submitting.

So most likely, you need to recode your data.

Regards,
Martin
 

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,771
Messages
2,569,587
Members
45,097
Latest member
RayE496148
Top