encodeURI

P

polilop

I'm having problems encoding URI. I have a page in which I use
XMLHttpRequest
to send a request. In my request it is possible to have Central European
characters.
When i send the request through mozilla, the URL is encoded (the character Z
in to %AE)
my problem is that IE dose not encode the character, it tourns it into ?,
and if I use the
javascript encodeURI for the same Character (Z) i get %C5%BD,
i have set the header to "Content-Type",
"application/x-www-form-urlencoded;8859-2"
and my page is saved in 8859-2.
So how can i make IE encode or even the javascript encodeURI function to
encode like Mozilla?
 
M

Martin Honnen

polilop said:
i have set the header to "Content-Type",
"application/x-www-form-urlencoded;8859-2"

The correct form for the header would be
"application/x-www-form-urlencoded; charset=ISO-8859-2"
However if you set that header then it is up to your code to make sure
the argument passed to the send method has that encoding and charset.
If you use the JavaScript functions encodeURI or encodeURIComponent then
the charset is _not_ ISO-8859-2 but rather UTF-8 thus if you use those
functions then you should use
"application/x-www-form-urlencoded; charset=UTF-8"
 
P

polilop

First of all thanks a lot, been googling for few day's and couldn't find
anywhere that the
encodeURI function only encode's UTF-8, so this workes fine for me
Martin Honnen
If you use the JavaScript functions encodeURI or encodeURIComponent then
the charset is _not_ ISO-8859-2 but rather UTF-8 thus if you use those
functions then you should use
"application/x-www-form-urlencoded; charset=UTF-8"


but if its not too much bother..
Martin Honnen
The correct form for the header would be
"application/x-www-form-urlencoded; charset=ISO-8859-2"
However if you set that header then it is up to your code to make sure the
argument passed to the send method has that encoding and charset.

How can i make this work (for 8859-2) with javascript if encodeURI only
encode's the UTF-8, and
why do mozilla and IE differently get the encoding?

Thanks for the help
 

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,774
Messages
2,569,599
Members
45,163
Latest member
Sasha15427
Top