Frédéric Marchal wrote: > I was looking at how QString::toLocal8bit works and, on Windows, it > looks like it may enter an infinite loop. > > If I got it right, QString::toLocal8Bit_helper calls > QTextCodec::fromUnicode which, on Windows, calls > QWindowsLocalCodec::convertFromUnicode in qwindowscodec.cpp.
Specifically, QWindowsLocalCodec::convertFromUnicode(). > In that function, if WideCharToMultiByte fails because the input > string is not a valid unicode string, the function displays a qWarning > where it helpfully output the offending string using > QString::toLocal8bit! > > If the string cannot be converted in the first place, it won't be > possible to convert it a second time to display the warning > message. Hence the infinite loop. Beautiful - well spotted. > It looks to me like the string should be displayed using > QString::toUtf8. The qWarning's format string even claims it is in UTF-8. > Am I right? Yes, you are. > Is it worth opening a QTBUG for this? Doing so would help track the matter (I have a fix, but may struggle to construct a test-case - if you have one, please do let me know, either by e-mail or in the bug report), but is not crucial: I have a patch in preparation, ready for review (but for a test-case), https://codereview.qt-project.org/#/c/155517/ Eddy. _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
