473,385 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Unescaping ASP vbscript escaped string

We are trying write a new ASP.NET page to work with an existing
stateless ASP application. The ASP application creates a cookie and
of course stores the cookie values as escaped strings (using the
vbscript escape function). I am have a terrible time 'unescaping'
that string with C# under ASP.NET.

I have tried the following:
HttpUtility.UrlDecode
HttpUtility.HtmlDecode (this should not work but I tried it)
System.Web.HttpContext.Current.Server.UrlDecode
System.Web.HttpContext.Current.Server.HtmlDecode (tried this too)

They all return the same string back or a slightly unescaped version.
Is there something about the way VBScript's escape works that is not
compatible with UrlDecode? Is there something about accessing this
through HttpCookie that changes things? Will I have to write my own
function to decode this or is there some other functions I can access
that will do this?

Thanks
Nov 18 '05 #1
2 8406
It should be trivial to write your own function to unescape-- simply walk
the string character by character. If the string contains a % then the next
two characters should be digits. Convert the %xx to a character of value
xx. If the % is followed by a character "u", the next 4 characters are
digits containing a character value.

Note that the VBScript escape function is not the same as URL Encode.
--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

"Vance Kessler" <vk******@peachtree.com> wrote in message
news:ae*************************@posting.google.co m...
We are trying write a new ASP.NET page to work with an existing
stateless ASP application. The ASP application creates a cookie and
of course stores the cookie values as escaped strings (using the
vbscript escape function). I am have a terrible time 'unescaping'
that string with C# under ASP.NET.

I have tried the following:
HttpUtility.UrlDecode
HttpUtility.HtmlDecode (this should not work but I tried it)
System.Web.HttpContext.Current.Server.UrlDecode
System.Web.HttpContext.Current.Server.HtmlDecode (tried this too)

They all return the same string back or a slightly unescaped version.
Is there something about the way VBScript's escape works that is not
compatible with UrlDecode? Is there something about accessing this
through HttpCookie that changes things? Will I have to write my own
function to decode this or is there some other functions I can access
that will do this?

Thanks

Nov 18 '05 #2
The solution is to use JScript unescape function. Like this:
using Microsoft.JScript;
..
..
..
System.Web.HttpCookie oCookie = Request.Cookies["<NameOfCookieDomain>"];
string sEscapedValue = oCookie.Values["<NameOfCookie>"];
string sValue = Server.UrlDecode(sEscapedValue);
sValue = Microsoft.JScript.GlobalObject.unescape(sValue);
vk******@peachtree.com (Vance Kessler) wrote in message news:<ae*************************@posting.google.c om>...
We are trying write a new ASP.NET page to work with an existing
stateless ASP application. The ASP application creates a cookie and
of course stores the cookie values as escaped strings (using the
vbscript escape function). I am have a terrible time 'unescaping'
that string with C# under ASP.NET.

I have tried the following:
HttpUtility.UrlDecode
HttpUtility.HtmlDecode (this should not work but I tried it)
System.Web.HttpContext.Current.Server.UrlDecode
System.Web.HttpContext.Current.Server.HtmlDecode (tried this too)

They all return the same string back or a slightly unescaped version.
Is there something about the way VBScript's escape works that is not
compatible with UrlDecode? Is there something about accessing this
through HttpCookie that changes things? Will I have to write my own
function to decode this or is there some other functions I can access
that will do this?

Thanks

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Anders Both | last post by:
If I receive a query string on the server that contains escaped chars like this: text=%20asadfdsf%20%C6%D8%C5%20%E6%F8%E5%20AAA How can I then get the NameValueCollection where the escaped...
2
by: Frank | last post by:
Can I do this? I add a session var in C# and ultimatly want to pass it into a vbscript client side activeX control. This is what I have so far but get " Object Required:'name2' " error. Can...
7
by: Jonny | last post by:
Hi, I am trying to write a C function which will dequote the string in a char * variable, and unescape any escaped quotes, so that, for example: "hello" would become: hello
13
by: Oxns | last post by:
Hi, Can anyone point me at the class to convert a string so that it displays escaped chars as \r, \n etc. please Its done in the 2005 debugger so I hope its available as a class ??. Thanks...
5
by: Micha Gancarski | last post by:
Hello! How do one unescape strings prepared with pg_escape_string() ? stripslashes() will not work because both these functions are not completely compatible. Thank you all in advance --...
4
by: Trev | last post by:
Hi everyone, Thanks to all who have helped with various issues in the past. I've come up with a new one though: I've run some html through a javascript converter; basically it takes the html and...
3
by: John Nagle | last post by:
Here's a URL from a link on the home page of a major company. <a href="/adsk/servlet/index?siteID=123112&amp;id=1860142">About Us</a> Yes, that "&amp;" is in the source text of the page. This is, in...
12
by: Torsten Bronger | last post by:
Hallchen! I need some help with finding matches in a string that has some characters which are marked as escaped (in a separate list of indices). Escaped means that they must not be part of...
9
by: Michael Goerz | last post by:
Hi, I am writing unicode stings into a special text file that requires to have non-ascii characters as as octal-escaped UTF-8 codes. For example, the letter "Í" (latin capital I with acute,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.