473,671 Members | 2,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 25680
"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.Ht mlEncode'.

--
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.HTM LEncode() 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.HTM LEncode() function

--
Bits.Bytes
http://bytes.thinkersroom.com
Jan 4 '07 #4
"Dennis" <De****@discuss ions.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&qu ot; 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.atschre ef in bericht
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
"Dennis" <De****@discuss ions.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&qu ot; 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.nlschri eb:
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
2367
by: Nedo | last post by:
hi is there a simple way to convert a html-string to a plain text-string? thanks Nedo
2
2625
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 actually want the font size to increase/decrease as the image grows/shrinks much the way text does in a flash object. Is there an easy way to do this programmatically? It needs to be done behind the scenes on my web site - user enters some text - I...
1
2792
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 Vb.Net I want some body simplify it for me ? And I want to use TextBox instaed of RichTextBox if possibale .. The Code:
2
2872
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 because i want to preserve the html, and replace some of the plain text. i basically want to show the user's search terms highlighted in the page, like google does, but i want to do this server side (i have the mechanics of intercepting the html...
1
2022
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 can I use this code in VB.Net ? The Code : With ALLText
0
1262
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 can I use this code in VB.Net ? The Code : With ALLText
3
2322
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 there an API to get the right plain text? TIA.
0
1870
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 if I mix plain text with html formatted text and set the isBodyHTML = true that I get a continuous line of plain text without carriage returns and proper HTML. I've a checkbox that if checked sets the IsBodyHTML=true.
0
1478
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. Best regards
0
8390
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8911
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8667
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5692
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4402
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2808
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.