Unicode and querystring!

H

Hans

Is it possible to put a unicode string on a querystring? How do I
escape/unescape this? I read values from a dropown list which may have any
UTF-8 character (chinese, greek or whatever).

If it is not possible I guess I have to post in the value instead but I
would like to keep the code as it is and only change the escape functions
which only works for ISO Latin characterset as far as I know.


Regards
/Hans
 
M

Martin Honnen

Hans said:
Is it possible to put a unicode string on a querystring? How do I
escape/unescape this? I read values from a dropown list which may have any
UTF-8 character (chinese, greek or whatever).

If it is not possible I guess I have to post in the value instead but I
would like to keep the code as it is and only change the escape functions
which only works for ISO Latin characterset as far as I know.

With Netscape 6/7, Mozilla, IE5.5/6 and with Opera 7 there is
encodeURIComponent(string)
which is capable of processing Unicode strings, for instance
var string = '€';
encodeURIComponent(string)
yields
%E2%82%AC
which is an escaped UTF-8 encoding. It is then up to you to handle that
properly on the server, if you have ASP on the server make sure you
install JScript 5.5 or 5.6 there and you can simply use
decodeURIComponent
In some browsers escape is also Unicode capable however it yields a
different result e.g.
var string = '€';
escape(string)
yields
%u20AC
which is % as the escape character, u for unicode and then the hex code
of the Unicode code value.
 

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

Similar Threads

Unicode 20
Python Unicode handling wins again -- mostly 67
Thinking Unicode 0
Unicode questions 17
unicode 7
Unicode (UTF-8) in C 13
Can't wrap text around image and one more 1
tkinter unicode question 0

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top