Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > What is the .Net equivalent of jscript escape/unescape?

Reply
Thread Tools

What is the .Net equivalent of jscript escape/unescape?

 
 
=?Utf-8?B?SGFycnkgS2Vjaw==?=
Guest
Posts: n/a
 
      03-09-2005
Is there a set of methods in the .Net framework that do the same thing as the
jscript functions escape and unescape?

I get very close with HttpUtility.UrlEncodeUnicode, but it puts "+" for
spaces instead of "%20". Uri.EscapeString seems to create the correct escape
string, but there is no unescape. The function is not public anyway, so I
probably shouldn't use it.

I need a way to escape text on the client, and then unescape it on the
server, and then escape it on the server, and unescape it out on the client.
How can I do this? Thanks.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VGltIFN0YWxs?=
Guest
Posts: n/a
 
      03-09-2005
Hello,
Because UrlEncode gets very close, I wrote my own methods that just wraps
that and adds some extra functionality (like replacing the apostrophe ' to
avoid cross-site-scripting warnings).

I provide sample code and charts of what UrlEncode escapes at this blog entry:
http://timstall.dotnetdevelopersjour...ad/1092094.htm

For example:

public static string UrlFullEncode(string strUrl)
{
if (strUrl == null)
return "";
strUrl = System.Web.HttpUtility.UrlEncode(strUrl);
return strUrl.Replace("'",_strApostropheEncoding);
}
private const string _strApostropheEncoding = "%27";

public static string UrlFullDecode(string strUrl)
{
if (strUrl == null)
return "";
strUrl = strUrl.Replace(_strApostropheEncoding,"'");
return System.Web.HttpUtility.UrlDecode(strUrl);
}



"Harry Keck" wrote:

> Is there a set of methods in the .Net framework that do the same thing as the
> jscript functions escape and unescape?
>
> I get very close with HttpUtility.UrlEncodeUnicode, but it puts "+" for
> spaces instead of "%20". Uri.EscapeString seems to create the correct escape
> string, but there is no unescape. The function is not public anyway, so I
> probably shouldn't use it.
>
> I need a way to escape text on the client, and then unescape it on the
> server, and then escape it on the server, and unescape it out on the client.
> How can I do this? Thanks.

 
Reply With Quote
 
 
 
Reply

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
JScript equivalent of getElementById Daan Javascript 6 10-31-2007 10:31 PM
What is Server-Side Jscript (not Jscript.NET)? Maxwell2006 ASP .Net 5 03-07-2006 05:28 AM
JScript.Net (JScript 7.0) is official documented language VK Javascript 4 01-12-2006 06:48 PM
Porting from JScript to JScript.Net - compiler error Jon Maz ASP .Net 4 09-09-2004 10:24 AM
Which to Learn: Javascript, Jscript, JScript.NET, ECMA 262 (3rd ed)? John Bentley Javascript 14 02-05-2004 06:14 PM



Advertisments