Skip to content

Commit

Permalink
Outsource new line replacements into new StripNewLines() function
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarbecker committed Apr 12, 2024
1 parent dec0ace commit 010a46c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 7 additions & 0 deletions source/apphelpers.pas
Expand Up @@ -334,6 +334,7 @@ TAppSettings = class(TObject)
function IsFloat(Str: String): Boolean;
function ScanLineBreaks(Text: String): TLineBreaks;
function fixNewlines(txt: String): String;
procedure StripNewLines(var txt: String; Replacement: String=' ');
function GetLineBreak(LineBreakIndex: TLineBreaks): String;
procedure RemoveNullChars(var Text: String; var HasNulls: Boolean);
function GetShellFolder(FolderId: TGUID): String;
Expand Down Expand Up @@ -828,6 +829,12 @@ function fixNewlines(txt: String): String;
result := txt;
end;

procedure StripNewLines(var txt: String; Replacement: String=' ');
begin
txt := StringReplace(txt, #13#10, Replacement, [rfReplaceAll]);
txt := StringReplace(txt, #13, Replacement, [rfReplaceAll]);
txt := StringReplace(txt, #10, Replacement, [rfReplaceAll]);
end;

function GetLineBreak(LineBreakIndex: TLineBreaks): String;
begin
Expand Down
4 changes: 1 addition & 3 deletions source/exportgrid.pas
Expand Up @@ -948,9 +948,7 @@ procedure TfrmExportGrid.btnOKClick(Sender: TObject);

// Remove linebreaks, see #474
if chkRemoveLinebreaks.Checked then begin
Data := StringReplace(Data, #13#10, ' ', [rfReplaceAll]);
Data := StringReplace(Data, #13, ' ', [rfReplaceAll]);
Data := StringReplace(Data, #10, ' ', [rfReplaceAll]);
StripNewLines(Data);
end;

case ExportFormat of
Expand Down

0 comments on commit 010a46c

Please sign in to comment.