mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
FIX: [Zip plugin] UTF-8 support in Zips on Linux (don't convert names to Ansi).
This commit is contained in:
parent
c69d0b80a2
commit
6e6c44d3b9
3 changed files with 33 additions and 14 deletions
|
|
@ -406,6 +406,9 @@ uses
|
|||
AbConst
|
||||
{$IFDEF MSWINDOWS}
|
||||
, AbExcept
|
||||
{$ENDIF}
|
||||
{$IFDEF UNIX}
|
||||
, osConvEncoding
|
||||
{$ENDIF}
|
||||
;
|
||||
|
||||
|
|
@ -1863,10 +1866,28 @@ begin
|
|||
end;
|
||||
|
||||
{$IFDEF LINUX}
|
||||
var
|
||||
GotEncoding: Boolean = False;
|
||||
IsSysLangUtf8: Boolean = False;
|
||||
|
||||
function AbSysCharSetIsUTF8: Boolean;
|
||||
|
||||
function InternalIsUTF8: Boolean;
|
||||
var
|
||||
Language, Encoding: String;
|
||||
begin
|
||||
Result := GetSystemEncoding(Language, Encoding);
|
||||
if Result then
|
||||
Result := SameText(Encoding, 'UTF8');
|
||||
end;
|
||||
|
||||
begin
|
||||
//Result := StrComp(nl_langinfo(_NL_CTYPE_CODESET_NAME), 'UTF-8') = 0;
|
||||
Result := False;
|
||||
if not GotEncoding then
|
||||
begin
|
||||
GotEncoding := True;
|
||||
IsSysLangUtf8 := InternalIsUTF8;
|
||||
end;
|
||||
Result := IsSysLangUtf8;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
|
|
|
|||
|
|
@ -1710,37 +1710,37 @@ begin
|
|||
FItemInfo.LoadFromStream( Stream );
|
||||
|
||||
if FItemInfo.IsUTF8 or (AbDetectCharSet(FItemInfo.FileName) = csUTF8) then
|
||||
FileName := UTF8ToString(FItemInfo.FileName)
|
||||
inherited SetFileName(FItemInfo.FileName)
|
||||
else if FItemInfo.ExtraField.Get(Ab_InfoZipUnicodePathSubfieldID, Pointer(InfoZipField), FieldSize) and
|
||||
(FieldSize > SizeOf(TInfoZipUnicodePathRec)) and
|
||||
(InfoZipField.Version = 1) and
|
||||
(InfoZipField.NameCRC32 = AbCRC32Of(FItemInfo.FileName)) then begin
|
||||
SetString(UTF8Name, InfoZipField.UnicodeName,
|
||||
FieldSize - SizeOf(TInfoZipUnicodePathRec) + 1);
|
||||
FileName := UTF8ToString(UTF8Name);
|
||||
inherited SetFileName(UTF8Name);
|
||||
end
|
||||
else if FItemInfo.ExtraField.Get(Ab_XceedUnicodePathSubfieldID, Pointer(XceedField), FieldSize) and
|
||||
(FieldSize > SizeOf(TXceedUnicodePathRec)) and
|
||||
(XceedField.Signature = Ab_XceedUnicodePathSignature) and
|
||||
(XceedField.Length * SizeOf(WideChar) = FieldSize - SizeOf(TXceedUnicodePathRec) + SizeOf(WideChar)) then begin
|
||||
SetString(UnicodeName, XceedField.UnicodeName, XceedField.Length);
|
||||
FileName := string(UnicodeName);
|
||||
inherited SetFileName(string(UnicodeName));
|
||||
end
|
||||
else
|
||||
begin
|
||||
SystemCode := TAbZipHostOs(Byte(VersionMadeBy shr 8));
|
||||
{$IF DEFINED(MSWINDOWS)}
|
||||
if (GetACP <> GetOEMCP) and (SystemCode = hosMSDOS) or IsOEM(FItemInfo.FileName) then
|
||||
FileName:= AbStrOemToAnsi(FItemInfo.FileName)
|
||||
inherited SetFileName(AbStrOemToAnsi(FItemInfo.FileName))
|
||||
else
|
||||
{$ELSEIF DEFINED(LINUX)}
|
||||
if (SystemCode = hosMSDOS) then
|
||||
FileName := OEMToSys(FItemInfo.FileName)
|
||||
inherited SetFileName(OEMToSys(FItemInfo.FileName))
|
||||
else if (SystemCode = hosNTFS) then
|
||||
FileName := AnsiToSys(FItemInfo.FileName)
|
||||
inherited SetFileName(AnsiToSys(FItemInfo.FileName))
|
||||
else
|
||||
{$ENDIF}
|
||||
FileName := string(FItemInfo.FileName);
|
||||
inherited SetFileName(FItemInfo.FileName);
|
||||
end;
|
||||
|
||||
IsDirectory := ((FItemInfo.ExternalFileAttributes and faDirectory) <> 0) or
|
||||
|
|
@ -2031,11 +2031,7 @@ begin
|
|||
FullSourceFileName := IncludeTrailingPathDelimiter(FullSourceFileName);
|
||||
end;
|
||||
|
||||
if TAbZipHostOS((VersionMadeBy shr 8) and $FF) = hosMSDOS then
|
||||
Result.FileName := AbStrAnsiToOem(FullArchiveFileName)
|
||||
else
|
||||
Result.FileName := FullArchiveFileName;
|
||||
|
||||
Result.FileName := FullArchiveFileName;
|
||||
Result.DiskFileName := FullSourceFileName;
|
||||
end;
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ function SysToOEM(Source: String): String;
|
|||
function AnsiToSys(Source: String): String;
|
||||
function SysToAnsi(Source: String): String;
|
||||
|
||||
function GetSystemEncoding(out Language, Encoding: String): Boolean;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue