diff --git a/mdx.cc b/mdx.cc index a861c1c6..b4815e2f 100644 --- a/mdx.cc +++ b/mdx.cc @@ -56,7 +56,7 @@ using namespace Mdict; enum { kSignature = 0x4349444d, // MDIC - kCurrentFormatVersion = 8 + BtreeIndexing::FormatVersion + kCurrentFormatVersion = 8 + BtreeIndexing::FormatVersion + Folding::Version }; DEF_EX( exCorruptDictionary, "dictionary file was tampered or corrupted", std::exception ) diff --git a/wstring_qt.cc b/wstring_qt.cc index 110989d2..75daf08d 100644 --- a/wstring_qt.cc +++ b/wstring_qt.cc @@ -10,19 +10,6 @@ namespace gd return QString::fromUcs4( in.c_str() ); } - wstring toWString( QString const & in ) - { - QVector< unsigned int > v = in.toUcs4(); - - // Fix for CJK Extension B characters - int n = v.size(); - while( n > 0 && v[ n - 1 ] == 0 ) n--; - if( n != v.size() ) - v.resize( n ); - - return wstring( v.constData(), v.size() ); - } - #else QString toQString( wstring const & in ) @@ -30,9 +17,20 @@ namespace gd return QString::fromStdWString( in ); } + #endif + wstring toWString( QString const & in ) { - return in.toStdWString(); + QVector< unsigned int > v = in.toUcs4(); + + // Fix for QString instance which contains non-BMP characters + // Qt will created unexpected null characters may confuse btree indexer. + // Related: https://bugreports.qt-project.org/browse/QTBUG-25536 + int n = v.size(); + while ( n > 0 && v[ n - 1 ] == 0 ) n--; + if ( n != v.size() ) + v.resize( n ); + + return wstring( ( const wchar * ) v.constData(), v.size() ); } - #endif }