1. Home
  2. Computing & Technology
  3. Delphi Programming

Delete line breaks from a string

By Zarko Gajic, About.com

Here's how to remove line breaks (#10, #13) from a string (replacing em with space):

~~~~~~~~~~~~~~~~~~~~~~~~~
function DeleteLineBreaks(const S: string): string;
var
   Source, SourceEnd: PChar;
begin
   Source := Pointer(S) ;
   SourceEnd := Source + Length(S) ;
   while Source < SourceEnd do
   begin
     case Source^ of
       #10: Source^ := #32;
       #13: Source^ := #32;
     end;
     Inc(Source) ;
   end;
   Result := S;
End;

~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Two (or more) line Hint box
« Flip Bitmap (Horizontal or Vertical)

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2002 Delphi Tips
  7. Delete line breaks from a string

©2009 About.com, a part of The New York Times Company.

All rights reserved.