By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,161 Members | 2,002 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,161 IT Pros & Developers. It's quick & easy.

HTML Hex Encoding

P: n/a
Does anyone know how and if it's possible to convert a
string like:

<div><a href="http://www.cnn.com">www.cnn.com</a></div>
<div>test string</div>

to something like this:

"\u003cdiv\u003e\u003ca href=\u0022http://www.cnn.com\u0022
\u003ewww.cnn.com\u003c/a\u003e\u003c/div\u003e\r\n\u003cdi
v\u003etest string\u003c/div\u003e"

I would like to do this using some kind of encoding
without having to escape each special character if possible

Any suggestions is greatly appreciated.
Thanks
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
use the HttpUtility.UrlEncode Method

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET)
Microsoft Certified Application Developer (.NET)
http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"cboekhoudt" <an*******@discussions.microsoft.com> wrote in message
news:ca****************************@phx.gbl...
Does anyone know how and if it's possible to convert a
string like:

<div><a href="http://www.cnn.com">www.cnn.com</a></div>
<div>test string</div>

to something like this:

"\u003cdiv\u003e\u003ca href=\u0022http://www.cnn.com\u0022
\u003ewww.cnn.com\u003c/a\u003e\u003c/div\u003e\r\n\u003cdi
v\u003etest string\u003c/div\u003e"

I would like to do this using some kind of encoding
without having to escape each special character if possible

Any suggestions is greatly appreciated.
Thanks

Nov 18 '05 #2

P: n/a
UrlEncode would give me something like
%3cdiv%3e%3ca+href%3d%22http%3a%2f%2fwww.cnn.com%2 2%
3ewww.cnn.com%3c%2fa%3e%3c%2fdiv%3e%3cdiv%3etest+s tring%3
UrlEncode is not what I need.

I need it to escape characters that are html specific such
as < > and include " '. Other than manually replace all
these with the hex, are there any special encodings that
will do it for me?

Thanks,
-----Original Message-----
use the HttpUtility.UrlEncode Method

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET)
Microsoft Certified Application Developer (.NET)
http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services"cboekhoudt" <an*******@discussions.microsoft.com> wrote in messagenews:ca****************************@phx.gbl...
Does anyone know how and if it's possible to convert a
string like:

<div><a href="http://www.cnn.com">www.cnn.com</a></div>
<div>test string</div>

to something like this:

"\u003cdiv\u003e\u003ca href=\u0022http://www.cnn.com\u0022 \u003ewww.cnn.com\u003c/a\u003e\u003c/div\u003e\r\n\u003cdi v\u003etest string\u003c/div\u003e"

I would like to do this using some kind of encoding
without having to escape each special character if possible
Any suggestions is greatly appreciated.
Thanks

.

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.