🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.web
Article #1234

Re: how to convert text to html

#1234
From: Hans Galema
Date: Wed, 14 Sep 2005 12:49
55 lines
2056 bytes
viv wrote:

> Hello james,
> How are you?
> 
> then it should be converted to html as follows:
> 
> <html>
> <head>
> <title></title>
> </head>
> <body>
> <p>Hello james,</p>
> <p>How are you?</p>
> </body>
> </html>

So you want every line to be in a paragraph tag.
Put all text in a TStringList and then add the
tag's for every line:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
   AnsiString Text = "Hello james,\r\n"
                     "How are you?\r\n";


   TStringList *StringList = new TStringList;

   StringList->Text = Text;

   int nr = -1;

   while ( ++nr < StringList->Count )
      StringList->Strings[nr] = "<p>" + StringList->Strings[nr] + "</p> ";


  // Now add the relevant htmlcode before and after

   StringList->Text =
      "<html>\r\n"
      "<head>\r\n"
      "<title></title>\r\n"
      "</head>\r\n"
      "<body>\r\n"
      + StringList->Text
      + "</body>\r\n"
        "</html>";

   ShowMessage ( StringList->Text );

   delete StringList;
}

Hans.
Technical Details
Message-ID: <43281c12$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.spamkiller.net!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <43280c18$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,7e03cd2599fed9
X-Google-Attributes: gidfeeec,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Wed, 14 Sep 2005 14:49:09 +0200
From: Hans Galema <notused@notused.nl>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.internet.web
Subject: Re: how to convert text to html
References: <43280c18$1@newsgroups.borland.com>
In-Reply-To: <43280c18$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 145.98.201.248
Message-ID: <43281c12$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1126702098 145.98.201.248 (14 Sep 2005 05:48:18 -0700)
Lines: 55
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.spamkiller.net!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail