mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Default single-byte text encoding option
This commit is contained in:
parent
0eb417d153
commit
78120eb2f3
2 changed files with 24 additions and 7 deletions
|
|
@ -3,7 +3,7 @@
|
|||
-------------------------------------------------------------------------
|
||||
Encoding conversion and related stuff
|
||||
|
||||
Copyright (C) 2011-2018 Alexander Koblov (alexx2000@mail.ru)
|
||||
Copyright (C) 2011-2022 Alexander Koblov (alexx2000@mail.ru)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -30,6 +30,7 @@ uses
|
|||
|
||||
const
|
||||
EncodingOem = 'oem';
|
||||
EncodingNone = 'none';
|
||||
EncodingDefault = 'default';
|
||||
EncodingUTF16LE = 'utf16le';
|
||||
EncodingUTF16BE = 'utf16be';
|
||||
|
|
@ -49,7 +50,7 @@ implementation
|
|||
|
||||
uses
|
||||
SysUtils, LazUTF8, LConvEncoding, GetText, DCConvertEncoding,
|
||||
DCUnicodeUtils, nsCore, nsUniversalDetector, uLng;
|
||||
DCUnicodeUtils, nsCore, nsUniversalDetector, uLng, uGlobs;
|
||||
|
||||
var
|
||||
Lang, FallbackLang: AnsiString;
|
||||
|
|
@ -402,15 +403,23 @@ function DetectEncoding(const S: String): String;
|
|||
var
|
||||
L, P: Integer;
|
||||
EndPos: Integer;
|
||||
UserEncoding: Boolean;
|
||||
begin
|
||||
UserEncoding:= (gDefaultTextEncoding <> EncodingNone);
|
||||
|
||||
L:= Length(S);
|
||||
if L = 0 then begin
|
||||
Result:= GetDefaultTextEncoding;
|
||||
if L = 0 then
|
||||
begin
|
||||
if UserEncoding then
|
||||
Result:= gDefaultTextEncoding
|
||||
else begin
|
||||
Result:= GetDefaultTextEncoding;
|
||||
end;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
// Try detect Unicode
|
||||
case DetectEncoding(S, meOEM, False) of
|
||||
case DetectEncoding(S, meOEM, UserEncoding) of
|
||||
meUTF8: Exit(EncodingUTF8);
|
||||
meUTF8BOM: Exit(EncodingUTF8BOM);
|
||||
meUTF16LE: Exit(EncodingUTF16LE);
|
||||
|
|
@ -428,8 +437,12 @@ begin
|
|||
Exit;
|
||||
end;
|
||||
|
||||
// Try to detect encoding
|
||||
Result:= MyDetectCodePageType(S);
|
||||
if UserEncoding then
|
||||
Result:= gDefaultTextEncoding
|
||||
else begin
|
||||
// Try to detect encoding
|
||||
Result:= MyDetectCodePageType(S);
|
||||
end;
|
||||
end;
|
||||
|
||||
function SingleByteEncoding(TextEncoding: String): Boolean;
|
||||
|
|
|
|||
|
|
@ -563,6 +563,7 @@ var
|
|||
gDescCreateUnicode: Boolean;
|
||||
gDescReadEncoding: TMacroEncoding;
|
||||
gDescWriteEncoding: TMacroEncoding;
|
||||
gDefaultTextEncoding: String;
|
||||
|
||||
{ Auto refresh page }
|
||||
gWatchDirs: TWatchOptions;
|
||||
|
|
@ -1949,6 +1950,7 @@ begin
|
|||
gDescReadEncoding:= meUTF8;
|
||||
gDescWriteEncoding:= meUTF8BOM;
|
||||
gDescCreateUnicode:= True;
|
||||
gDefaultTextEncoding:= EncodingNone;
|
||||
|
||||
{ Auto refresh page }
|
||||
gWatchDirs := [watch_file_name_change, watch_attributes_change];
|
||||
|
|
@ -2994,6 +2996,7 @@ begin
|
|||
gHotDirFilenameStyle := TConfigFilenameStyle(GetValue(Node, 'FilenameStyle', ord(gHotDirFilenameStyle)));
|
||||
gHotDirPathToBeRelativeTo := gConfig.GetValue(Node, 'PathToBeRelativeTo', gHotDirPathToBeRelativeTo);
|
||||
gHotDirPathModifierElements := tHotDirPathModifierElements(GetValue(Node, 'PathModifierElements', Integer(gHotDirPathModifierElements)));
|
||||
gDefaultTextEncoding := GetValue(Node, 'DefaultTextEncoding', gDefaultTextEncoding);
|
||||
end;
|
||||
|
||||
{ Thumbnails }
|
||||
|
|
@ -3637,6 +3640,7 @@ begin
|
|||
SetValue(Node, 'FilenameStyle', ord(gHotDirFilenameStyle));
|
||||
SetValue(Node, 'PathToBeRelativeTo', gHotDirPathToBeRelativeTo);
|
||||
SetValue(Node, 'PathModifierElements', Integer(gHotDirPathModifierElements));
|
||||
SetValue(Node, 'DefaultTextEncoding', gDefaultTextEncoding);
|
||||
|
||||
{ Thumbnails }
|
||||
Node := FindNode(Root, 'Thumbnails', True);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue