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. QCollator doesn't sort in DUCET/CLDR order
Qt 6.11 is out! See what's new in the release blog

QCollator doesn't sort in DUCET/CLDR order

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 358 Views
  • 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.
  • CrinC Offline
    CrinC Offline
    Crin
    wrote on last edited by
    #1

    Good day all,

    I'm attempting to use QCollator to generate and index in the standard DUCET/CDLR order, as given in unicode.org collation chart, but am having no luck, certain characters (eg overline and $) are resolutely sorted incorrectly.

    Here's a tiny bit of test code:

         QCollator collator;
         collator.setLocale(QLocale("en_GB")); // what are the values for collation strategy keys?
         collator.setIgnorePunctuation(false);
    
         QVector<QString> v = {" space [whitespace]", "$ dollar [currency]", "% percent [punctuation]", "2 two [digit]", "1 one [digit]", "‾ overline [punctuation]", "+ plus [symbol]", "< less than [symbol]","# hash [punctuation]"};
         
         std::sort(v.begin(), v.end(), collator);
         qDebug() << v;
    
    

    This produces the following output:

     QVector(" space [whitespace]", "# hash [punctuation]", "$ dollar [currency]", "% percent [punctuation]", "? overline [punctuation]", "+ plus [symbol]", "< less than [symbol]", "1 one [digit]", "2 two [digit]")
    

    but I'm expecting (hoping for) this order:

    QVector(" space [whitespace]", "? overline [punctuation]", "# hash [punctuation]", "% percent [punctuation]", "+ plus [symbol]", "< less than [symbol]", "$ dollar [currency]", "1 one [digit]", "2 two [digit]")
    

    i.e. I'm expecting the ordering specified here: https://unicode.org/charts/collation/

    So the overline character should be the first of the set of punctuation characters
    and the $ character should appear after the [symbols] ... ?

    Any idea what I'm doing wrong?

    Many thanks!

    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