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

Delete line breaks from a string

By , About.com Guide

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)

Explore Delphi Programming
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. 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

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

All rights reserved.