Menu

#2168 Qt case-insensitive search fails for µ in ISO 8859-1 encoding

Bug
closed-fixed
5
2020-04-27
2020-04-09
No

With Qt 5.12 on Win32, encoding set to default (ISO 8859-1), searching for 'µ' also matches '?'.

'µ' (Micro Sign) case folds to 'μ' (Greek Small Letter Mu). QTextCodec::codecForName("ISO 8859-1") converts Greek Small Letter Mu to '?' indicating a failure but this is treated as valid. Therefore search text and document text 'µ' (Micro Sign) is tested as '?' and so matches '?'.

The solution is to check QTextCodec::canEncode before performing the fromUnicode as in this patch:

diff -r 82b2210d3a1c qt/ScintillaEditBase/ScintillaQt.cpp
--- a/qt/ScintillaEditBase/ScintillaQt.cpp  Fri Apr 10 08:16:50 2020 +1000
+++ b/qt/ScintillaEditBase/ScintillaQt.cpp  Fri Apr 10 09:27:43 2020 +1000
@@ -575,9 +575,11 @@
                    sCharacter[0] = i;
                    QString su = codec->toUnicode(sCharacter, 1);
                    QString suFolded = su.toCaseFolded();
-                   QByteArray bytesFolded = codec->fromUnicode(suFolded);
-                   if (bytesFolded.length() == 1) {
-                       pcf->SetTranslation(sCharacter[0], bytesFolded[0]);
+                   if (codec->canEncode(suFolded)) {
+                       QByteArray bytesFolded = codec->fromUnicode(suFolded);
+                       if (bytesFolded.length() == 1) {
+                           pcf->SetTranslation(sCharacter[0], bytesFolded[0]);
+                       }
                    }
                }
                return pcf;

Discussion

  • Neil Hodgson

    Neil Hodgson - 2020-04-10
    • status: open --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2020-04-10

    Fix committed as [b28166].

     

    Related

    Commit: [b28166]

  • Neil Hodgson

    Neil Hodgson - 2020-04-27
    • status: open-fixed --> closed-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2020-04-27

    Fix committed as [b28166].

     

    Related

    Commit: [b28166]


Log in to post a comment.