471,073 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

Unicode and querystring!

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
Jul 20 '05 #1
2 5305


Hans wrote:
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.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Thanks Martin!

/Hans
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Raterus | last post: by
12 posts views Thread by Alex | last post: by
reply views Thread by prasanta.bhowmik | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.