Solved How to convert QString to ASCII ?
-
I need something like this:
if ( "a" == "b" -1 ) ......
ASCII:
if ( 97 == 98 - 1 ) ...... -
@sonichy
see QChar::toLatin1() which returns achar
which also can be cast to anint
to get the QChar, use QString::at() -
@sonichy said in How to convert QString to ASCII ?:
I need something like this:
if ( "a" == "b" -1 ) ......Use single quotes instead of double quotes:
if ( 'a' == 'b' -1 )
this is pure C++, nothing Qt specific -
@raven-worx said in How to convert QString to ASCII ?:
cast to an int
QString a = ...; QString b = ...; ushort as = a.at(0).unicode(); ushort bs = b.at(0).unicode(); qDebug() << a << as << b << bs; if(as != bs-1) return false;
-
QByteArray a_ascii = a.toLatin1();