Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Escaping unicode characters!

Thread Tools

Escaping unicode characters!

Posts: n/a

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%>
<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">

<script language="javascript">
function run()
document.frm.action="test.asp?id=" + escape(document.frm.txt.value);
//document.frm.action="test.asp?id=" +

'#######End file test.asp###########


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unicode escaping fun & games Andrew S. Townley Ruby 0 04-23-2009 04:19 PM
<c:out/> and escaping of unicode format Java 0 10-27-2008 09:06 PM
Unicode digit to unicode string Gabriele *darkbard* Farina Python 2 05-16-2006 01:15 PM
unicode wrap unicode object? ygao Python 6 04-08-2006 09:54 AM
Unicode + jsp + mysql + tomcat = unicode still not displaying Robert Mark Bram Java 0 09-28-2003 05:37 AM