Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Is Qt library support Unicode?



  • Is Qt library support Unicode and MBCS? In a Qt Creator project, how can I set the project to produce Unicode or MBCS executables?


  • Moderators

    "QString":http://doc-snapshot.qt-project.org/4.8/qstring.html automatically stores Unicode strings. You don't need to do set anything special.



  • Qt's own String class, QString, is Unicode all the way. Its internal representation/encoding is UTF-16, always. If you need the "raw" UTF-16 string data, use QString::utf16(). Note that you may need to cast the pointer returned by that function to wchar_t* before you can pass it into Win32 API functions (or any other function that uses the wchar_t* type), because it returns a ushort* pointer. If you need a "multi-byte" representation of the QString, you may use QString::toUtf8(), QString::toAscii() or QString::toLocal8Bit() as needed. All three functions return a QByteArray, from which you can get the "raw" string as char* via QByteArray::constData().



  • Thank you so much.


Log in to reply