mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Revert "clean code: win return std::string directly"
This reverts commit0669455298
. Revert "clean code:remove old temporary fix" This reverts commitc941a5bfc3
.
This commit is contained in:
parent
67c74136e8
commit
4c32f756e5
|
@ -21,7 +21,7 @@ string encode( wstring const & str )
|
|||
string encode( string const & str )
|
||||
{
|
||||
#ifdef __WIN32
|
||||
return str;
|
||||
return string( str );
|
||||
#else
|
||||
return string( QString::fromUtf8( str.c_str() ).toLocal8Bit().data() );
|
||||
#endif
|
||||
|
|
|
@ -10,7 +10,17 @@ namespace gd
|
|||
|
||||
wstring toWString( QString const & in )
|
||||
{
|
||||
return in.toStdU32String();
|
||||
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() );
|
||||
}
|
||||
|
||||
wstring normalize( const wstring & str )
|
||||
|
|
Loading…
Reference in a new issue