More Group Sites
School Rankings
Jobless Net
Better Home
Enviro++


Help | Subscribe/Unsubscribe | Rules | Other Group Sites: Better Education | Better Education Forum
Welcome Guest Search | Active Topics | Members | Log In | Register

How to add a CR/LF pair (new line) to the end (or middle) of a string in Delphi? Options · View
hong
Posted: Thursday, June 11, 2009 7:35:02 AM

Rank: Administration
Groups: Administration

Joined: 11/23/2008
Posts: 335
Points: 711
Location: Australia
How to add a CR/LF pair (new line) to the end (or middle) of a string in Delphi?

Code:
//CR = #13 and LF = #10
'line1' + #13#10 +'line2';


The line termination character sequence is operating system dependent - CRLF (Windows/MS DOS), LF (Unix) and CR (Macintosh). As a result, moving text files between systems without conversion can cause pretty severe problems, eg. Notepad just shows the Unix terminators as boxes. See the following snippets for the conversion.

Code:
const
  strLineBreak = {$IFDEF LINUX} AnsiChar(#10) {$ENDIF}
               {$IFDEF MSWINDOWS} AnsiString(#13#10) {$ENDIF};



Code:
strNew := stringreplace(oldstring, string_or_character_to_replace, string_or_character_to_replace_with, [rfreplaceall]);

example:
strNewData := stringreplace(strOldData, #10, #13#10, [rfreplaceall]);


Related:
Newline in other programming languages
C\C++ - "\n";
VisualBasic - vbNewLine;
Java - newLine().
Sponsor
Posted: Thursday, June 11, 2009 7:35:02 AM
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

ASPNET Theme created by Boskone (Dan Ferguson)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.
This page was generated in 0.135 seconds.