[Interest] Is it safe to use QString::utf16() as a Windows wchar_t*?
Nikos Chantziaras
realnc at gmail.com
Thu Nov 9 10:15:28 CET 2017
On Windows, I use this:
void func(const wchar_t*);
QString s;
// ...
func(reinterpret_cast<const wchar_t*>(s.utf16()));
This saves an allocation, a copy and a free since I don't have to use
QString::toWCharArray(). However, is this actually safe? "It seems to
work," and AFAIK, QString::d->data() is already in the format and
encoding Windows excepts a wchar_t* to be. Is this correct?
More information about the Interest
mailing list