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

Convert plain text string to HTML

Is there anything built in to vb.net that will take a plain text string
and reformat it as HTML? What I mean is:

o replace newlines with <BR>
o replace " with &quot;
o etc.

I am using vb.net 2003.

Thanks,

--

Dennis
Jan 3 '07 #1
6 25597
"Dennis" <no****@imyisp.invalidschrieb:
Is there anything built in to vb.net that will take a plain text string
and reformat it as HTML? What I mean is:

o replace newlines with <BR>
o replace " with &quot;
o etc.

I am using vb.net 2003.

The simplest way to do this is using 'Replace'. In addition check out
'HttpUtility.HtmlEncode'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jan 3 '07 #2
On Wed, 03 Jan 2007 11:19:00 -0500, Dennis wrote:
Is there anything built in to vb.net that will take a plain text string
and reformat it as HTML? What I mean is:

o replace newlines with <BR>
o replace " with &quot;
o etc.

I am using vb.net 2003.

Thanks,
For the <BRyou'll have to make do with the string.replace(). For the
other html entities like &quot; &gt; etc you can use the
HttpUtility.HTMLEncode() function

--
Bits.Bytes
http://bytes.thinkersroom.com
Jan 3 '07 #3
Just curious as to why replace with &quot, etc. I generate an HTML code
within VB from a database and save it as an HTM file. It displays fine in
internet explorer. Is there some problem if I were to send this page via
e-mail or something?
--
Dennis in Houston
"Rad [Visual C# MVP]" wrote:
On Wed, 03 Jan 2007 11:19:00 -0500, Dennis wrote:
Is there anything built in to vb.net that will take a plain text string
and reformat it as HTML? What I mean is:

o replace newlines with <BR>
o replace " with "
o etc.

I am using vb.net 2003.

Thanks,

For the <BRyou'll have to make do with the string.replace(). For the
other html entities like " etc you can use the
HttpUtility.HTMLEncode() function

--
Bits.Bytes
http://bytes.thinkersroom.com
Jan 4 '07 #4
"Dennis" <De****@discussions.microsoft.comschrieb:
Just curious as to why replace with &quot, etc. I generate an HTML code
within VB from a database and save it as an HTM file. It displays fine in
internet explorer. Is there some problem if I were to send this page via
e-mail or something?
There is generally no reason to use '&quot;' instead of the double quotation
mark character except if the encoding used to save the file does not contain
the character (which is very unlikely nowadays) or in attribute values
surrounded by double quotation marks.

Valid XHTML:

* '<img src="1.gif" alt="Bla &quot;Bla&quot; Bla"/>'
* '<img src="1.gif" alt='Bla "Bla" Bla'/>'

Invalid XHTML:

* '<img src="1.gif" alt="Bla "Bla" Bla"/>'

The same applies to '&apos;' vs. the single quotation mark character.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jan 4 '07 #5
Herfried,

In my idea is the double space still a problem
&nbsp

Cor

"Herfried K. Wagner [MVP]" <hi***************@gmx.atschreef in bericht
news:%2****************@TK2MSFTNGP06.phx.gbl...
"Dennis" <De****@discussions.microsoft.comschrieb:
>Just curious as to why replace with &quot, etc. I generate an HTML code
within VB from a database and save it as an HTM file. It displays fine
in
internet explorer. Is there some problem if I were to send this page via
e-mail or something?

There is generally no reason to use '&quot;' instead of the double
quotation mark character except if the encoding used to save the file does
not contain the character (which is very unlikely nowadays) or in
attribute values surrounded by double quotation marks.

Valid XHTML:

* '<img src="1.gif" alt="Bla &quot;Bla&quot; Bla"/>'
* '<img src="1.gif" alt='Bla "Bla" Bla'/>'

Invalid XHTML:

* '<img src="1.gif" alt="Bla "Bla" Bla"/>'

The same applies to '&apos;' vs. the single quotation mark character.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jan 4 '07 #6
"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
In my idea is the double space still a problem
&nbsp
Which double space?

'&nbsp;' is not the same as " ". The first one is a non-breaking space
(thus '&nbsp;') which prevents insertion of soft line breaks.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jan 4 '07 #7

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

Similar topics

4
by: Nedo | last post by:
hi is there a simple way to convert a html-string to a plain text-string? thanks Nedo
2
by: UJ | last post by:
I have need to convert a text string (with formatting) to an image. This is so that I can resize the image to different sizes and the formatting stays exactly the same regardless of the size. I...
1
by: Husam | last post by:
Hi EveryBody: I have this code which convert RTF Text to HTML ? but I think it is written by vb.classic, I want some body help my in writting this code by Vb.Net ? but if it is already writen by...
2
by: Tim_Mac | last post by:
hi, i have a tricky problem and my regex expertise has reached its limit. i have read other posts on this newsgroup that pull out the plain text from a html string, but that won't work for me...
1
by: Husam | last post by:
Hi EveryBody: I got this code from one newsgroup in google, the one who post this code claim that this code convert Text to HTML , if that is right can Any body help me and expline for me how...
0
by: Husam | last post by:
Hi EveryBody: I got this code from one newsgroup in google, the one who post this code claim that this code convert Text to HTML , if that is right can Any body help me and expline for me how...
3
by: Gary | last post by:
I am wondering what is the fastest way to get plain text such as "abc def 12" from an HTML string. I can parse it, but not sure how to deal with those special characters, such as & and >. Is...
0
by: Rey | last post by:
Howdy all. Am using visual web developer 2005 (vb), xp pro sp2. In testing of the system.net.mail to send email from an aspx page where I'm pulling the email contents from a textbox, find that...
0
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I need to convert doc, xls, pdf, rtf to plain Text. It should work like: string s = ConvertToText(@"C:\temp\text.doc"); What is the best component to use ?? Thanks for any comments....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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:
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...
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...

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.