H
Hans
Hi!
Can someone explain how ASP works when it comes to unicode characters on the
querystring? See the testcode below. If you type in a chinese character in
the first textbox and click "post" the javascript code will change the
action for the <form> and add the text entered in the first editbox to the
querystring and then submit the form. Then the value on the querystring (id)
will be presented in the second textbox.
1. In my example for example chinese characters will be OK regardless if I
use the javascript escape or encodeURIComponent. If I check
alert(escape(document.frm.txt.value)) or
alert(encodeURIComponent(document.frm.txt.value)); they are certainly not
the same but IIS seems to fix this anyway. Is this just a coincidence or is
IIS handling the querystring correct regardless if I use the escape or
encodeURIComponent? Is the request object doing a implicit unescape for me?
2. The javascript escape should according to my reference guide not support
unicode characters but If I run the example below and use escape and type in
a chinese character it is show correct after I submit. I must be missing
something here (this maybe is a javascript thing but....)
'#######Name file test.asp###########
<%@ Language=VBSCRIPT CodePage=65001%>
<html>
<body>
<meta Content-Type="text/html" Charset="utf-8">
<form name="frm" action="test.asp" method="post">
<input type="text" name="txt">
<input type="text" name="txt2" value="<%=request.querystring("id")%>">
<input type="button" onclick="run();" value="post">
</form>
<script language="javascript">
function run()
{
document.frm.action="test.asp?id=" + escape(document.frm.txt.value);
//document.frm.action="test.asp?id=" +
encodeURIComponent(document.frm.txt.value);
document.frm.submit();
}
</script>
</body>
</html>
'#######End file test.asp###########
Regards
/Hans
Can someone explain how ASP works when it comes to unicode characters on the
querystring? See the testcode below. If you type in a chinese character in
the first textbox and click "post" the javascript code will change the
action for the <form> and add the text entered in the first editbox to the
querystring and then submit the form. Then the value on the querystring (id)
will be presented in the second textbox.
1. In my example for example chinese characters will be OK regardless if I
use the javascript escape or encodeURIComponent. If I check
alert(escape(document.frm.txt.value)) or
alert(encodeURIComponent(document.frm.txt.value)); they are certainly not
the same but IIS seems to fix this anyway. Is this just a coincidence or is
IIS handling the querystring correct regardless if I use the escape or
encodeURIComponent? Is the request object doing a implicit unescape for me?
2. The javascript escape should according to my reference guide not support
unicode characters but If I run the example below and use escape and type in
a chinese character it is show correct after I submit. I must be missing
something here (this maybe is a javascript thing but....)
'#######Name file test.asp###########
<%@ Language=VBSCRIPT CodePage=65001%>
<html>
<body>
<meta Content-Type="text/html" Charset="utf-8">
<form name="frm" action="test.asp" method="post">
<input type="text" name="txt">
<input type="text" name="txt2" value="<%=request.querystring("id")%>">
<input type="button" onclick="run();" value="post">
</form>
<script language="javascript">
function run()
{
document.frm.action="test.asp?id=" + escape(document.frm.txt.value);
//document.frm.action="test.asp?id=" +
encodeURIComponent(document.frm.txt.value);
document.frm.submit();
}
</script>
</body>
</html>
'#######End file test.asp###########
Regards
/Hans