From 920c7b71854620edc39b65908ba87279514dc3ea Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Tue, 28 May 2024 01:43:06 +0200 Subject: [PATCH] Fixed https://sourceforge.net/p/sevenzip/bugs/1060/ --- CPP/7zip/Archive/Zip/ZipItem.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CPP/7zip/Archive/Zip/ZipItem.cpp b/CPP/7zip/Archive/Zip/ZipItem.cpp index a5aaca99..d0a6739f 100644 --- a/CPP/7zip/Archive/Zip/ZipItem.cpp +++ b/CPP/7zip/Archive/Zip/ZipItem.cpp @@ -434,17 +434,23 @@ void CItem::GetUnicodeString(UString &res, const AString &s, bool isComment, boo "wa_BE", "CP1252", "zh_HK", "CP950", "zh_SG", "CP936"}; bool isOem = false; + bool isAnsi = false; if (!isUtf8 && - (MadeByVersion.HostOS == NFileHeader::NHostOS::kNTFS || - MadeByVersion.HostOS == NFileHeader::NHostOS::kFAT)) { + MadeByVersion.HostOS == NFileHeader::NHostOS::kNTFS && + MadeByVersion.Version >= 20) { + isAnsi = true; + } else + if (!isUtf8 && + (MadeByVersion.HostOS == NFileHeader::NHostOS::kNTFS || + MadeByVersion.HostOS == NFileHeader::NHostOS::kFAT)) { isOem = true; } const char *legacyCp = nullptr; const char *legacyCpAnsi = nullptr; - if (isOem || (useSpecifiedCodePage && (codePage != 65001))) { + if (isOem || isAnsi || (useSpecifiedCodePage && (codePage != 65001))) { int tableLen = sizeof(lcToOemTable) / sizeof(lcToOemTable[0]); int lcLen = 0, i; @@ -483,7 +489,7 @@ void CItem::GetUnicodeString(UString &res, const AString &s, bool isComment, boo } iconv_t cd; - if ((cd = iconv_open("UTF-8", useSpecifiedCodePage ? specCP : legacyCp)) != (iconv_t)-1) { + if ((cd = iconv_open("UTF-8", useSpecifiedCodePage ? specCP : (isOem ? legacyCp : legacyCpAnsi))) != (iconv_t)-1) { AString sUtf8;