473,399 Members | 3,401 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,399 software developers and data experts.

HTML Hex Encoding

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
2 3889
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Cantor | last post by:
Hello everyone :) I am writing some dotNET code to "consume" a web service written in PHP. So far I have been getting some error messages and PHP seems to place HTML text in front of the XML...
11
by: Ron | last post by:
Hello, I'm having an aggravating time getting the "html" spewed by Word 2003 to display correctly in a webpage. The situation here is that the people creating the documents only know Word, and...
24
by: chri_schiller | last post by:
I have a home-made website that provides a free 1100 page physics textbook. It is written in html and css. I recently added some chinese text, and since that day there are problems. The entry...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
82
by: Eric Lindsay | last post by:
I have been trying to get a better understanding of simple HTML, but I am finding conflicting information is very common. Not only that, even in what seemed elementary and without any possibility...
3
by: Dale Strickland-Clark | last post by:
A colleague has asked me this and I don't know the answer. Can anyone here help with this? Thanks in advance. Here is his email: I am trying to parse an HTML document using the xml.dom.minidom...
14
by: Zoro | last post by:
My task is to read html files from disk and save them onto SQL Server database field. I have created an nvarchar(max) field to hold them. The problem is that some characters, particularly html...
5
by: Timothy Madden | last post by:
Hello Is there a function that will allow me to output text written in utf-8 (from db for example) if my document has Content-Type: text/html; charset=ISO-8859-1 I mean htmlspecialchars()...
6
by: clintonG | last post by:
Can anybody make sense of this crazy and inconsistent results? // IE7 Feed Reading View disabled displays this raw XML <?xml version="1.0" encoding="utf-8" ?> <!-- AT&T HTML entities & XML...
3
by: anu b | last post by:
Hii I am using System.net.mail for sending email... i need to send a webpage with its html content as my email body .....for that i used mail.Isbodyhtml as true...but it is not working for me...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.