ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder
ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 ImageEnFolderMView sort doesn't match Windows
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Waheed

Kuwait
20 Posts

Posted - Oct 17 2019 :  16:13:28  Show Profile  Reply
ImageEnFolderMView sort order doesn't match Windows (10) sort order when using filename and international characters.
Using ImageEnFolderMView demo I opened the same folder as in Windows Explorer but look at the end of the list of files in the given image.





-----------------
3 Monitors
Windows 10
Delphi 6,2007 and 10.2
ImageEn v.8.7

xequte

4891 Posts

Posted - Oct 17 2019 :  21:37:11  Show Profile  Reply
Hi Waheed

ImageEn uses either CompareStr (case-sensitive) or CompareText(not case-sensitive) to handle the sorting. Do you know of an alternative method?



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Waheed

Kuwait
20 Posts

Posted - Oct 17 2019 :  23:08:48  Show Profile  Reply
It's not only strings, also special characters like
[
is not in the correct order.



I'm no expert, but I would look into these pages thoroughly :

https://stackoverflow.com/questions/2279789/comparing-and-sorting-unicode-filenames

https://docs.microsoft.com/en-us/windows/win32/intl/handling-sorting-in-your-applications?redirectedfrom=MSDN



-----------------
3 Monitors
Windows 10
Delphi 6,2007 and 10.2
ImageEn v.8.7
Go to Top of Page

xequte

4891 Posts

Posted - Oct 17 2019 :  23:23:18  Show Profile  Reply
Hi Waheed

Please test StrCmpLogicalW:

https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-strcmplogicalw

In a TStringList as outlined in the Delphi code here:

https://stackoverflow.com/questions/5134712/how-to-get-the-sort-order-in-delphi-as-in-windows-explorer

How does that compare to CompareText?



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Waheed

Kuwait
20 Posts

Posted - Oct 19 2019 :  00:09:31  Show Profile  Reply
I test multiple methods of sorting (I did select custom sort and added this to the OnSortCompare event:
CompareStringW and CompareStringEx took too long that I had to terminate it.

case cmbSortType.ItemIndex of
    0: Result := StrCmpLogicalW(PWideChar(Filename1),PWideChar(Filename2));
    1: Result := CompareStringW(LOCALE_CUSTOM_DEFAULT, LINGUISTIC_IGNOREDIACRITIC,
             PWideChar(Filename1), length(PWideChar(Filename1)), PWideChar(Filename2), length(PWideChar(Filename2)));
    2: Result := CompareStringEx(LOCALE_NAME_INVARIANT, 0, PWideChar(Filename1), -1, PWideChar(Filename2), -1, nil, nil, 0);
    3: Result := CompareStringOrdinal(PWideChar(Filename1),  length(PWideChar(Filename2)), PWideChar(Filename2),  length(PWideChar(Filename2)), true);
   end;


Is this the correct way of implementing these methods?

-----------------
3 Monitors
Windows 10
Delphi 6,2007 and 10.2
ImageEn v.8.7
Go to Top of Page

xequte

4891 Posts

Posted - Oct 19 2019 :  15:36:40  Show Profile  Reply
Hi

Those looks correct. Did any of them give more favorable sorting?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Waheed

Kuwait
20 Posts

Posted - Oct 20 2019 :  22:31:01  Show Profile  Reply
No, none made a difference. Here is the list of file names for anyone to test. You can just create/duplicate a file, then rename it using the provided names.

attach/Waheed/20191020223043_FolderView.txt

-----------------
3 Monitors
Windows 10
Delphi 6,2007 and 10.2
ImageEn v.8.7
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: