Skip to content

Commit

Permalink
Revert "clean code: win return std::string directly"
Browse files Browse the repository at this point in the history
This reverts commit 0669455.

Revert "clean code:remove old temporary fix"

This reverts commit c941a5b.
  • Loading branch information
xiaoyifang committed Apr 7, 2022
1 parent 67c7413 commit 4c32f75
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fsencoding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion wstring_qt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down

0 comments on commit 4c32f75

Please sign in to comment.