PDA

View Full Version : QString checking whether in ASCII range



raj_iv
29th April 2011, 13:55
I have a QString as input. The string may contain Unicode text as well. I want to check whether a character is in Extended ASCII range (0-255). How to do this...pls help

MarekR22
29th April 2011, 15:31
QChar::toLatin1()!=0

high_flyer
29th April 2011, 17:45
I want to check whether a character is in Extended ASCII range (0-255).
So I guess you mean you want to know if a char value is greater than 127, since below that its not extended ascii.
Iterating over the string char by char as Mark suggested is not very efficient, specially for larger strings.
You can use QRegExp to match all char above 127 with \\0x80-\\0x255.