PDA

View Full Version : toAscii() in Qt5



TorAn
19th March 2013, 19:02
I am looking for a suitable replacement of toAscii(), since it is deprecated in Qt5.

Is


QString str("test");
const char* ptr = (const char*) (str.utf16());


a good substitute for toAscii()?

Advise/comment is appreciated, thanks.

wysota
20th March 2013, 00:21
I am looking for a suitable replacement of toAscii(),
toLatin1(), as the docs say.


Is


QString str("test");
const char* ptr = (const char*) (str.utf16());


a good substitute for toAscii()?

No, this is wrong. utf16() gives you utf-16 representation (not very hard to guess that) while toAscii() returns 8-bit representation.