[SOLVED]toAscii function depreciation what to use instead?
-
wrote on 28 Jul 2013, 01:18 last edited by
Hello, I want to write a small program, the program takes a STRING and converts it to ASCII code. The problem is that the toAscii function depreciated. I would like to know if there is another function that takes a STRING and converts it to ASCII.
Thank You
-
Hi,
Use QString::toLatin1()
-
wrote on 28 Jul 2013, 17:25 last edited by
Consider using toUtf8() so Unicode characters won't get destroyed!
Note: The ASCII characters (0x00 to 0x7F) are bit-identical to ASCII in UTF-8.
-
wrote on 29 Jul 2013, 01:17 last edited by
Hi, if you characters are really ASCII characters, any ASCII-compatible encode can be used, such as Latin1/Latin2/.../Latin11/Latin13/.../Latin15/Utf8/GB18030/...
All of these conversion can be done using QTextCodec::fromUnicode().
QString has provided the convenient QString::toLatin1()/QString::toUtf8(), depending on the your local, QString::toLacal8Bit() can be used too.
-
wrote on 29 Jul 2013, 14:06 last edited by
Thank you for your replies, they helped me solve the problem. Thanks again
2/5