Thursday, March 29, 2012

HTML Hex Encoding

Does anyone know how and if it's possible to convert a
string like:
<div><a href="http://links.10026.com/?link=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.
Thanksuse 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" <anonymous@.discussions.microsoft.com> wrote in message
news:ca1801c438fc$e91ca860$a001280a@.phx.gbl...
> Does anyone know how and if it's possible to convert a
> string like:
> <div><a href="http://links.10026.com/?link=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
UrlEncode would give me something like
%3cdiv%3e%3ca+href%3d%22http%3a%2f%2fwww
.cnn.com%22%
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" <anonymous@.discussions.microsoft.com> wrote
in message
>news:ca1801c438fc$e91ca860$a001280a@.phx.gbl...
href=\u0022http://www.cnn.com\u0022
\u003ewww.cnn.com\u003c/a\u003e\u003c/div\u003e\r\n\u003cdi
possible
>
>.
>

No comments:

Post a Comment