VladG
VladG

Reputation: 143

Do QString's toUpper()/toLower() member functions only convert Latin alpha characters?

According to the documentation QString's toUpper() and toLower() member functions convert in the C-locale. Does it mean that only Posix Portable Character Set characters (Latin A-Z/a-z) are converted and any international unicode characters are left as-is?

Upvotes: 1

Views: 2332

Answers (1)

Tzig
Tzig

Reputation: 851

We can easily test this with the simple test program here:

#include <QString>
#include <iostream>

int main()
{
    QString s("БΣTest3φب");

    std::cout << "String: " << s.toStdString() << std::endl;
    std::cout << "Lower: " << s.toLower().toStdString() << std::endl;
    std::cout << "Upper: " << s.toUpper().toStdString() << std::endl;

    return 0;
}

Which returns:

09:48:48: Starting /home/tzig/test/test ...
String: БΣTest3φب
Lower: бσtest3φب
Upper: БΣTEST3Φب
09:48:49: /home/tzig/test/test exited with code 0

So we know that:

  • Cyrillic letters work fine
  • Latin letters work fine
  • Numbers are untouched
  • Greek letters work fine
  • Arabic letters don't have uppercase/lowercase so they are untouched

Feel free to test other Unicode characters with the test program.

Upvotes: 3

Related Questions