Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-2987

Calling toCaseFolded twice on a Unicode character results in a different character than a single toCaseFolded

    XMLWordPrintable

Details

    Description

      This causes the case insensitive indexOf function to not work correctly for unicode characters.

      #include <QtGui> 
       
      int main() 
      { 
          enum { Count = 2 }; 
          const QChar chars[Count] = { QChar('E'), QChar(1025) }; 
          for (int i=0; i<Count; ++i) { 
              const QChar &unicode = chars[i]; 
              const QChar folded = unicode.toCaseFolded(); 
              const QChar foldedTwice = folded.toCaseFolded(); 
              qDebug() << "haystack" << unicode.unicode() << "haystack folded" << folded.unicode() 
                       << "haystack folded twice" << foldedTwice.unicode(); 
       
              const QString needle = unicode; 
              const QString hayStack = needle.toLower(); 
              qDebug() << "found needle" << hayStack.indexOf(needle, 0, Qt::CaseInsensitive) 
                       << "should be the same" << hayStack.toLower().indexOf(needle.toLower()); 
          } 
          return 0; 
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            dzyubenk Denis Dzyubenko (Inactive)
            mch Jervey Kong
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes