mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
ZIPS: Change handling of UTF-8 encoded file names
This commit is contained in:
parent
eac157af29
commit
6238f33d1f
|
@ -187,32 +187,35 @@ bool IndexedZip::indexFile( BtreeIndexing::IndexedWords &zipFileNames )
|
|||
// Failed to decode
|
||||
}
|
||||
|
||||
// CP866
|
||||
try
|
||||
if( !entry.fileNameInUTF8 )
|
||||
{
|
||||
wstring decoded = Iconv::toWstring( "CP866", entry.fileName.constData(),
|
||||
entry.fileName.size() );
|
||||
// CP866
|
||||
try
|
||||
{
|
||||
wstring decoded = Iconv::toWstring( "CP866", entry.fileName.constData(),
|
||||
entry.fileName.size() );
|
||||
|
||||
zipFileNames.addSingleWord( decoded,
|
||||
entry.localHeaderOffset );
|
||||
}
|
||||
catch( Iconv::Ex )
|
||||
{
|
||||
zipFileNames.addSingleWord( decoded,
|
||||
entry.localHeaderOffset );
|
||||
}
|
||||
catch( Iconv::Ex )
|
||||
{
|
||||
// Failed to decode
|
||||
}
|
||||
|
||||
// CP1251
|
||||
try
|
||||
{
|
||||
wstring decoded = Iconv::toWstring( "CP1251", entry.fileName.constData(),
|
||||
entry.fileName.size() );
|
||||
|
||||
zipFileNames.addSingleWord( decoded,
|
||||
entry.localHeaderOffset );
|
||||
}
|
||||
catch( Iconv::Ex )
|
||||
{
|
||||
// Failed to decode
|
||||
}
|
||||
|
||||
// CP1251
|
||||
try
|
||||
{
|
||||
wstring decoded = Iconv::toWstring( "CP1251", entry.fileName.constData(),
|
||||
entry.fileName.size() );
|
||||
|
||||
zipFileNames.addSingleWord( decoded,
|
||||
entry.localHeaderOffset );
|
||||
}
|
||||
catch( Iconv::Ex )
|
||||
{
|
||||
// Failed to decode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,6 +151,7 @@ bool readNextEntry( QFile & zip, CentralDirEntry & entry )
|
|||
entry.compressedSize = qFromLittleEndian( record.compressedSize );
|
||||
entry.uncompressedSize = qFromLittleEndian( record.uncompressedSize );
|
||||
entry.compressionMethod = getCompressionMethod( record.compressionMethod );
|
||||
entry.fileNameInUTF8 = ( qFromLittleEndian( record.gpBits ) & 0x800 ) != 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ struct CentralDirEntry
|
|||
|
||||
quint32 localHeaderOffset, compressedSize, uncompressedSize;
|
||||
CompressionMethod compressionMethod;
|
||||
bool fileNameInUTF8;
|
||||
};
|
||||
|
||||
/// Represents contents of the local file header -- that what CentralDirEntry::
|
||||
|
|
|
@ -44,7 +44,7 @@ DEF_EX( exInvalidData, "Invalid data encountered", Dictionary::Ex )
|
|||
enum
|
||||
{
|
||||
Signature = 0x5350495a, // ZIPS on little-endian, SPIZ on big-endian
|
||||
CurrentFormatVersion = 3 + BtreeIndexing::FormatVersion
|
||||
CurrentFormatVersion = 4 + BtreeIndexing::FormatVersion
|
||||
};
|
||||
|
||||
struct IdxHeader
|
||||
|
|
Loading…
Reference in a new issue