From 1ce48da37ffc115e81e401f917028486c76620c9 Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Tue, 28 May 2024 01:49:14 +0200 Subject: [PATCH] Fix 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 10153d68..adaaa6b4 100644 --- a/CPP/7zip/Archive/Zip/ZipItem.cpp +++ b/CPP/7zip/Archive/Zip/ZipItem.cpp @@ -533,17 +533,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; @@ -582,7 +588,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;