Author Topic: Sorting order for UTF8 ignores "-"  (Read 1109 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Sorting order for UTF8 ignores "-"
« on: October 08, 2021, 07:34:53 PM »
If I have a buffer with
Code: [Select]
-band
begin
-bnot
it sorts differently if it is ACP vs UTF-8
With UTF-8, apparently the leading "-" is ignored.

ACP Ordering:
Code: [Select]
-band
-bnot
begin
UTF8 Ordering
Code: [Select]
-band
begin
-bnot

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6685
  • Hero Points: 514
Re: Sorting order for UTF8 ignores "-"
« Reply #1 on: October 09, 2021, 01:43:21 AM »
Interesting. works for a line selection. Also works for the sort-buffer command. Odd when you use a column selection. We will look into this.

not sure how long this has been this way. v25 is the same.
« Last Edit: October 09, 2021, 01:59:41 AM by Clark »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6685
  • Hero Points: 514
Re: Sorting order for UTF8 ignores "-"
« Reply #2 on: October 10, 2021, 07:41:47 PM »
I'm not sure this is a bug. SlickEdit is calling the Win32 CompareStringW function which sorts this way. Make a directory and put the following file names in the new directory:

a
b
-c

Notice that the windows file explorer displays the sort order the same as SlickEdit.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6685
  • Hero Points: 514
Re: Sorting order for UTF8 ignores "-"
« Reply #3 on: October 10, 2021, 10:24:30 PM »
Decided not to use CompareStringsW.  This win32 function seems to always be case insentive which is definitely a bug. Also, SlickEdit file explorer like dialogs already don't use this function for Unicode. Might as well have all platforms do the same thing.

Thanks for noticing this weirdness.

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: Sorting order for UTF8 ignores "-"
« Reply #4 on: October 11, 2021, 12:09:43 AM »
Cool.

So, why would you be using a win32 function for sorting?
Wouldn't you want some portable function?

FWIW, I was just using gui-sort, and sorting the whole buffer.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6685
  • Hero Points: 514
Re: Sorting order for UTF8 ignores "-"
« Reply #5 on: October 11, 2021, 02:23:58 AM »
My original testing was flawed. All edit window sort commands were off.

Doing full featured Unicode string operations is very complicated. On non-windows platforms we just blow off all the complicated stuff.