Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unicode case folding
Qt 6.11 is out! See what's new in the release blog

Unicode case folding

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 1.6k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    imironchik
    wrote on last edited by
    #1

    How can I get form char "ẞ" unicode case folded "ss" in Qt 6?

    1 Reply Last reply
    0
    • kkoehneK Offline
      kkoehneK Offline
      kkoehne
      Moderators
      wrote on last edited by
      #2

      I'm not aware of any explicit (imperative) Qt API for this. Can you elaborate a bit on your use case?

      Director R&D, The Qt Company

      1 Reply Last reply
      0
      • I Offline
        I Offline
        imironchik
        wrote on last edited by
        #3

        CommonMark Markdown Spec needs such conversion

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mpergand
          wrote on last edited by
          #4

          QString germanB="\u00df";

          1 Reply Last reply
          0
          • kkoehneK Offline
            kkoehneK Offline
            kkoehne
            Moderators
            wrote on last edited by
            #5

            @imironchik said in Unicode case folding:

            CommonMark Markdown Spec needs such conversion

            So is your use case that you want to compare case folded strings , so that "ẞ" == "SS"?

            This might be working if you're directly using QCollator, and enable the ICU backend...

            Director R&D, The Qt Company

            1 Reply Last reply
            0
            • I Offline
              I Offline
              imironchik
              wrote on last edited by
              #6

              @kkoehne said in Unicode case folding:

              So is your use case that you want to compare case folded strings , so that "ẞ" == "SS"?

              Yes, it's so.

              This might be working if you're directly using QCollator, and enable the ICU backend...

              But I don't want to deal with the locale...

              1 Reply Last reply
              0
              • kkoehneK Offline
                kkoehneK Offline
                kkoehne
                Moderators
                wrote on last edited by kkoehne
                #7

                Well, per unicode standard,the case folded form of "ẞ" (Latin Capital Letter Sharp S, U+1E9E) is "ß" (Latin Small Letter Sharp S, U+00DF). That is also what QString::toCaseFolded() returns.

                What you can do is either doing comparisons via QCollator, which I believe should result in "ß" == "ss"at least for German locales. I don't know whether this also works for other locales though.

                Or you have to do a manual replacement by yourself ...

                Director R&D, The Qt Company

                1 Reply Last reply
                2
                • kkoehneK Offline
                  kkoehneK Offline
                  kkoehne
                  Moderators
                  wrote on last edited by
                  #8

                  Heh, this actually works :)

                  QString("ẞ").toCaseFolded().toUpper(); // does return "SS" for me
                  

                  Director R&D, The Qt Company

                  1 Reply Last reply
                  2
                  • I Offline
                    I Offline
                    imironchik
                    wrote on last edited by
                    #9

                    @kkoehne said in Unicode case folding:

                    Heh, this actually works :)

                    :) I guess that your locale is German.

                    Ok, guys, I understood you, so will mark this topic as solved.

                    1 Reply Last reply
                    1
                    • kkoehneK Offline
                      kkoehneK Offline
                      kkoehne
                      Moderators
                      wrote on last edited by
                      #10

                      @imironchik said in Unicode case folding:

                      :) I guess that your locale is German.

                      No, actually not. QString::toUpper() always operates in the C locale....

                      It seems that the definition in Unicode that ß should become SS when upper-cased predates the introduction of the upper case ẞ , and they didn't want to change this behavior ...

                      That was an interesting rabbit hole ;) You might still be better of handling this case explicitly in your logic though, who knows whether Unicode will change this at one point.

                      Director R&D, The Qt Company

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved