From 88c3560e6e137f26e9fe2e164f263fb497d2eeaa Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Thu, 20 Feb 2020 09:35:45 +0100 Subject: [PATCH] Issue #140: As a complement to writing tab backups in UTF8 without BOM, now load them in this encoding, not in UTF8 with BOM * see deab98736ed591b1aeb6a229de1ddf06e9f43a42 * see https://www.heidisql.com/forum.php?t=35551 --- source/apphelpers.pas | 7 +++---- source/main.pas | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/source/apphelpers.pas b/source/apphelpers.pas index 7e087c32..03de9358 100644 --- a/source/apphelpers.pas +++ b/source/apphelpers.pas @@ -378,6 +378,7 @@ var ConfirmIcon: TIcon; NumberChars: TSysCharSet; LibHandleUser32: THandle; + UTF8NoBOMEncoding: TUTF8NoBOMEncoding; implementation @@ -1112,13 +1113,10 @@ end; procedure SaveUnicodeFile(Filename: String; Text: String); var Writer: TStreamWriter; - Enc: TEncoding; begin - Enc := TUTF8NoBOMEncoding.Create; - Writer := TStreamWriter.Create(Filename, False, Enc); + Writer := TStreamWriter.Create(Filename, False, UTF8NoBOMEncoding); Writer.Write(Text); Writer.Free; - Enc.Free; end; @@ -4305,6 +4303,7 @@ NumberChars := ['0'..'9', FormatSettings.DecimalSeparator, FormatSettings.Thousa LibHandleUser32 := LoadLibrary('User32.dll'); +UTF8NoBOMEncoding := TUTF8NoBOMEncoding.Create; end. diff --git a/source/main.pas b/source/main.pas index aa0cfbd2..d18aeb9d 100644 --- a/source/main.pas +++ b/source/main.pas @@ -2297,7 +2297,7 @@ begin if FileExists(BackupFilename) then begin Tab := GetOrCreateEmptyQueryTab; Tab.Uid := Section; - Tab.LoadContents(BackupFilename, True, TEncoding.UTF8); + Tab.LoadContents(BackupFilename, True, UTF8NoBOMEncoding); Tab.MemoFilename := Filename; Tab.Memo.Modified := True; if EditorHeight > 50 then