Skip to content
Permalink
Browse files

Issue #140: Be sure to write tab backup files in UTF8 without BOM

  • Loading branch information...
ansgarbecker committed Oct 15, 2019
1 parent 10f6106 commit deab98736ed591b1aeb6a229de1ddf06e9f43a42
Showing with 17 additions and 1 deletion.
  1. +17 −1 source/apphelpers.pas
@@ -26,6 +26,11 @@ TOrderCol = class(TObject)

TLineBreaks = (lbsNone, lbsWindows, lbsUnix, lbsMac, lbsWide, lbsMixed);

TUTF8NoBOMEncoding = class(TUTF8Encoding)
public
function GetPreamble: TBytes; override;
end;

TDBObjectEditor = class(TFrame)
private
FModified: Boolean;
@@ -1119,10 +1124,13 @@ function GetTempDir: String;
procedure SaveUnicodeFile(Filename: String; Text: String);
var
Writer: TStreamWriter;
Enc: TEncoding;
begin
Writer := TStreamWriter.Create(Filename, False, TEncoding.UTF8);
Enc := TUTF8NoBOMEncoding.Create;
Writer := TStreamWriter.Create(Filename, False, Enc);
Writer.Write(Text);
Writer.Free;
Enc.Free;
end;


@@ -4227,6 +4235,14 @@ function TAppSettings.DirnameBackups: String;



{ TUTF8NoBOMEncoding }

function TUTF8NoBOMEncoding.GetPreamble: TBytes;
begin
SetLength(Result, 0);
end;


initialization

NumberChars := ['0'..'9', FormatSettings.DecimalSeparator, FormatSettings.ThousandSeparator];

0 comments on commit deab987

Please sign in to comment.
You can’t perform that action at this time.