473,386 Members | 1,773 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,386 software developers and data experts.

Equivalent of JavaScripts escape() and unescape()

Hello,

I am looking fow C# equivalent of JavaScripts escape() and unescape()
functions. I need to use C# function at the server side and then be able to
use the opposite at the client side.

JavaScripts escape() function converts all non-alphanumerical chars to %xx,
and all unicode chars to %uxxxx (where xxxx is unicode charcode). I'd like
to have C# function that get this escaped string back to normal at the
server side. Perhaps there is a built-in one?

I've beenu using System.Web.HttpUtility.UrlEncode till now, but it differs
from escape(). For example, JavasScript will not convert unescape('+') to
single space. It will differently treat unicode characters, too.

Of course, I could code these conversion functions myself, just was
wandering if there are ones already present in the deep forests of .NET
built-in classes.

Thanks,

Pavils
Nov 16 '05 #1
2 14455
"Pavils Jurjans" <pa****@mailbox.riga.lv> wrote in
news:uT**************@tk2msftngp13.phx.gbl:
Hello,

I am looking fow C# equivalent of JavaScripts escape() and
unescape() functions. I need to use C# function at the server
side and then be able to use the opposite at the client side.

JavaScripts escape() function converts all non-alphanumerical
chars to %xx, and all unicode chars to %uxxxx (where xxxx is
unicode charcode). I'd like to have C# function that get this
escaped string back to normal at the server side. Perhaps there
is a built-in one?

I've beenu using System.Web.HttpUtility.UrlEncode till now, but
it differs from escape(). For example, JavasScript will not
convert unescape('+') to single space. It will differently treat
unicode characters, too.

Of course, I could code these conversion functions myself, just
was wandering if there are ones already present in the deep
forests of .NET built-in classes.


Pavils,

You can use JScript.Net to create a server-side assembly (dll) that
exposes the escape and unescape methods (actually you should use the
encodeURI and decodeURI methods). Your server-side C# code could
call the methods in this assembly.

Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 16 '05 #2
Hi Chris,

Well, it's not URI I am trying to pass here. It's a custom-formatted string
data, that I just need to make transfer-safe. "escape" method is good as its
really short and present alway at the client side without need to add
additional encoding/decoding code. Thanks for the suggestion io get them to
server side via JScript DLL, I'll test whats faster - hand-made C# method or
the one in JScript dll.

Regards,
-- Pavils

"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
"Pavils Jurjans" <pa****@mailbox.riga.lv> wrote in
news:uT**************@tk2msftngp13.phx.gbl:
Hello,

I am looking fow C# equivalent of JavaScripts escape() and
unescape() functions. I need to use C# function at the server
side and then be able to use the opposite at the client side.

JavaScripts escape() function converts all non-alphanumerical
chars to %xx, and all unicode chars to %uxxxx (where xxxx is
unicode charcode). I'd like to have C# function that get this
escaped string back to normal at the server side. Perhaps there
is a built-in one?

I've beenu using System.Web.HttpUtility.UrlEncode till now, but
it differs from escape(). For example, JavasScript will not
convert unescape('+') to single space. It will differently treat
unicode characters, too.

Of course, I could code these conversion functions myself, just
was wandering if there are ones already present in the deep
forests of .NET built-in classes.


Pavils,

You can use JScript.Net to create a server-side assembly (dll) that
exposes the escape and unescape methods (actually you should use the
encodeURI and decodeURI methods). Your server-side C# code could
call the methods in this assembly.

Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/

Nov 16 '05 #3

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

Similar topics

2
by: Daniel | last post by:
I'm working with strings that contain xml escape codes, such as '0' and need a way in python to unescape these back to their ascii representation, such as '&' but can't seem to find a python method...
6
by: Paul Watson | last post by:
How can I get the escapes from a command line parameter interpreted? The user provides a string on the command line. The string might contain traditional escapes such as \t, \n, etc. It might...
3
by: harrelson | last post by:
I have a list of about 2500 html escape sequences (decimal) that I need to convert to utf-8. Stuff like: 비 행 기 로 보 낼 거
1
by: JigMan | last post by:
When chucking data in a cookie you cannot use certain characters (in this example ‘ : ‘ ). To get around this you use escape and unescape. Trying to use the escape as such: ...
4
by: swayze | last post by:
Hi, I'm sending some vars to php from javascript. These vars contain special chars (like "&" ,",")and also turkish characters. Therefore I'm using javascripts escape() function to be able to...
1
by: Harry Keck | last post by:
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...
0
by: gomzi | last post by:
hi, I would like to know as to what the equivalent functions are in .net for the escape and unescape functions that we have in javascript. tried both Server.HtmlEncode & Server.UrlEncode without...
1
by: Philipp | last post by:
How do I convert a string to escaped HTML? (Let's say I'm not using DOM.) E.g. "<p>foo</p>" would become "&lt;p&gt;foo&lt;/p&gt;"? Reversely, how do I unescape a string to be HTML? E.g. "&lt;em&gt;" would turn...
1
by: RK | last post by:
Perhaps I'm confused somwhere in my understanding, but I'm trying to deal with some escaped text from an XML file which includes html markup and it appears there are a couple of techniques for...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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.