Escaping unicode characters!

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top