mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 03:01:07 +08:00
Issue #140: Be sure to write tab backup files in UTF8 without BOM
This commit is contained in:
@ -26,6 +26,11 @@ type
|
||||
|
||||
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 @@ end;
|
||||
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 @@ end;
|
||||
|
||||
|
||||
|
||||
{ TUTF8NoBOMEncoding }
|
||||
|
||||
function TUTF8NoBOMEncoding.GetPreamble: TBytes;
|
||||
begin
|
||||
SetLength(Result, 0);
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
|
||||
NumberChars := ['0'..'9', FormatSettings.DecimalSeparator, FormatSettings.ThousandSeparator];
|
||||
|
Reference in New Issue
Block a user