locked
Hebrew Parameters in Query String RRS feed

  • Question

  • Hi, everyone.
    I'm trying to pass a Query String which contains some
    Hebrew parameters from javascript and read them in .aspx page
    But all i get is empty string instead of hebrew.

    any ideas?


    this is a code samples:

    in js page:
    window.location.href = "MyPage.aspx?ParamName="+hebPar+"&Date="+datePar;

    in aspx page:
    string str = Request.QueryString["ParamName"];
    Sunday, November 20, 2005 8:47 AM

Answers

All replies

  • Are you trying to pass the hebrew charcters in unicode foramt?
    you know that you cant put the characters in the paramater par of the url due to the stndard http protocol.
    i had a sinilar problem with arabic characters as quesry parameters, so I turned em into html unicde http://www.microsoft.com/globaldev/handson/dev/Mideast.mspx
    also look out for RightToLeftt issues in java script as is mentioned in the article.
    I be doing a web site in hebrew next :)
    Sunday, November 20, 2005 4:33 PM
  • I found folowing code on internet.
    call to encodeURIComponentNew(hebPar) to get Unicode string.

    looks a little creapy but i have no time to fix it now ;-). just place \r\n in the right places:

    var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-"; function encodeURIComponentNew(s) { var s = utf8(s); var c; var enc = ""; for (var i= 0; i=0xDC00 && c<0xE000) continue; if (c>=0xD800 && c<0xDC00) { if (i>=wide.length) continue; s= wide.charCodeAt(i++); if (s<0xDC00 || c>=0xDE00) continue; c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000; } // output value if (c<0x80) enc += String.fromCharCode(c); else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F)); else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F)); else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F)); } return enc; } var hexchars = "0123456789ABCDEF"; function toHex(n) { return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF); }
    Sunday, November 20, 2005 4:38 PM
  • Have you tried using the built in encodeURIComponent method?

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/17bab5a2-bcd4-46c2-8b52-b2b5a0ed98a3.asp

    window.location.href = "MyPage.aspx?ParamName="+encodeURIComponent(hebPar)+"&Date="+encodeURIComponent(datePar);

    Wednesday, January 4, 2006 5:29 PM
    Moderator
  • Thanks - This reply just proved useful to me over six years after it was given!
    Thursday, September 13, 2012 11:24 AM