Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How convert Qsting to const char * ?
tmtt66 last edited by
how convert Qsting to const char * on that support unicode format?
QString string("blah blah");
const char *raw = string.toUtf8().constData();
QtRoS last edited by
For UNICODE string I recommend the using of wchar_t* instead of char*. Or even QChar*. You can get it with data() method (note that size of QChar is 2 bytes like wchar_t in most of OS).
But if you want raw bytes - you must receive QByteArray first with one of methods like toUtf8 or toLatin1.
Quoting Unicode 4.0:
[quote]The width of wchar_t is compiler-specific and can be as small as 8 bits. Consequently, programs that need to be portable across any C or C++ compiler should not use wchar_t for storing Unicode text. The wchar_t type is intended for storing compiler-defined wide characters, which may be Unicode characters in some compilers.[/quote]
In any case, just as QtRoS hinted, you should stick qith Qt stuff as much as possible, as it's guaranteed to be cross-platform.