Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
unxed committed May 27, 2024
1 parent 4236682 commit 920c7b7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions CPP/7zip/Archive/Zip/ZipItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 920c7b7

Please sign in to comment.