Unicode and querystring!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hans

    #1

    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


  • Martin Honnen

    #2
    Re: Unicode and querystring!



    Hans wrote:
    [color=blue]
    > 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.[/color]

    With Netscape 6/7, Mozilla, IE5.5/6 and with Opera 7 there is
    encodeURICompon ent(string)
    which is capable of processing Unicode strings, for instance
    var string = '€';
    encodeURICompon ent(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
    decodeURICompon ent
    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/

    Comment

    • Hans

      #3
      Re: Unicode and querystring!

      Thanks Martin!

      /Hans


      Comment

      Working...