Skip to content

Commit

Permalink
opt: remove qtextcodec and refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang committed Jan 3, 2025
1 parent 22e7d04 commit bcf25d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/common/iconv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,5 @@ QString Iconv::findValidEncoding( const QStringList & encodings )
return encoding;
}
}
// Return utf-8 as fallback.
return QString( "UTF-8" );
return {};
}
6 changes: 5 additions & 1 deletion src/dict/utils/indexedzip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ bool IndexedZip::indexFile( BtreeIndexing::IndexedWords & zipFileNames, quint32
else {
try {
//detect encoding.
auto encoding = Iconv::findValidEncoding( { "LOCAL", "IBM437", "CP866", "CP1251" } );
auto encoding = Iconv::findValidEncoding( { "LOCAL", "IBM437", "CP866", "CP1251", "UTF-8" } );
if ( encoding.isEmpty() ) {
qWarning() << "Zip warning: failed to detect encoding -- skipping file" << entry.fileName.data();
continue;
}
std::u32string nameInSystemLocale =
Iconv::toWstring( encoding.toUtf8().constData(), entry.fileName.constData(), entry.fileName.size() );
if ( !nameInSystemLocale.empty() ) {
Expand Down

0 comments on commit bcf25d1

Please sign in to comment.