mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-30 17:24:08 +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
|
// Failed to decode
|
||||||
}
|
}
|
||||||
|
|
||||||
// CP866
|
if( !entry.fileNameInUTF8 )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
wstring decoded = Iconv::toWstring( "CP866", entry.fileName.constData(),
|
// CP866
|
||||||
entry.fileName.size() );
|
try
|
||||||
|
{
|
||||||
|
wstring decoded = Iconv::toWstring( "CP866", entry.fileName.constData(),
|
||||||
|
entry.fileName.size() );
|
||||||
|
|
||||||
zipFileNames.addSingleWord( decoded,
|
zipFileNames.addSingleWord( decoded,
|
||||||
entry.localHeaderOffset );
|
entry.localHeaderOffset );
|
||||||
}
|
}
|
||||||
catch( Iconv::Ex )
|
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
|
// 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.compressedSize = qFromLittleEndian( record.compressedSize );
|
||||||
entry.uncompressedSize = qFromLittleEndian( record.uncompressedSize );
|
entry.uncompressedSize = qFromLittleEndian( record.uncompressedSize );
|
||||||
entry.compressionMethod = getCompressionMethod( record.compressionMethod );
|
entry.compressionMethod = getCompressionMethod( record.compressionMethod );
|
||||||
|
entry.fileNameInUTF8 = ( qFromLittleEndian( record.gpBits ) & 0x800 ) != 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ struct CentralDirEntry
|
||||||
|
|
||||||
quint32 localHeaderOffset, compressedSize, uncompressedSize;
|
quint32 localHeaderOffset, compressedSize, uncompressedSize;
|
||||||
CompressionMethod compressionMethod;
|
CompressionMethod compressionMethod;
|
||||||
|
bool fileNameInUTF8;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Represents contents of the local file header -- that what CentralDirEntry::
|
/// Represents contents of the local file header -- that what CentralDirEntry::
|
||||||
|
|
|
@ -44,7 +44,7 @@ DEF_EX( exInvalidData, "Invalid data encountered", Dictionary::Ex )
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Signature = 0x5350495a, // ZIPS on little-endian, SPIZ on big-endian
|
Signature = 0x5350495a, // ZIPS on little-endian, SPIZ on big-endian
|
||||||
CurrentFormatVersion = 3 + BtreeIndexing::FormatVersion
|
CurrentFormatVersion = 4 + BtreeIndexing::FormatVersion
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IdxHeader
|
struct IdxHeader
|
||||||
|
|
Loading…
Reference in a new issue