View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0024740 | Lazarus | LCL | public | 2013-07-13 17:44 | 2013-07-24 14:59 |
Reporter | Anna | Assigned To | Bart Broersma | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | x86 | OS | WinXP SP3 Pro Russian | ||
Product Version | 1.1 (SVN) | ||||
Fixed in Version | 1.1 (SVN) | ||||
Summary | 0024740: TTreeView.AlphaSort does not sort russian (Cyrillic) symbols alphabetically | ||||
Description | before sort : http://img7.imageshack.us/img7/5414/6zco.png after sort : http://img163.imageshack.us/img163/5941/rfah.png Russian alphabet http://en.wikipedia.org/wiki/Russian_alphabet | ||||
Tags | No tags attached. | ||||
Fixed in Revision | r42123 | ||||
LazTarget | - | ||||
Widgetset | |||||
Attached Files |
|
|
|
|
'ppp' must be before 'www' (in this message i dont use russian chars , but transliteration) |
|
You could use either OnCompare event or use CustomSort with a specified SortProc: TTreeNodeCompare. TCustomTreeView.DefaultTreeViewSort could use Utf8CompareStr instead of AnsiCompareStr though. |
|
>>use CustomSort with a specified SortProc: TTreeNodeCompare. Does not work . procedure TForm1.Button1Click(Sender: TObject); function DefaultTreeViewSortEX(Node1, Node2: TTreeNode): Integer; begin Result := Utf8CompareStr(Node1.Text,Node2.Text); end; begin treeview1.AlphaSort; treeview1.CustomSort(@DefaultTreeViewSortEX); end; I get error unit1.pas(42,46) Error: Incompatible type for arg no. 1: Got "<address of function(TTreeNode;TTreeNode):LongInt;Register>", expected "<procedure variable type of function(TTreeNode;TTreeNode):LongInt of object;Register>" >>TCustomTreeView.DefaultTreeViewSort could use Utf8CompareStr instead of AnsiCompareStr though. I can patch treeview.inc , but in new installer this problem will come back. So can you patch installer ? Oh... Stupid windows code pages... It always works wrong... I hate russian! |
|
As far as I know, it is enough to write OnCompare handler and use AlphaSort. procedure TForm1.TreeView1Compare(Sender: TObject; Node1, Node2: TTreeNode; var Compare: Integer); begin Compare := UTF8CompareStr(Node1.Text, Node2.Text) end; |
|
There is another question: why TCustomTreeView.DefaultTreeViewSort use by default AnsiCompareStr (lcl\include\treeview.inc:3229) if we know than Node.Text is in UTF-8 encoding? |
|
There is a long discussion about sorting in this post. http://forum.lazarus.freepascal.org/index.php/topic,17454.0.html It seems everyone agrees that sorting is a problem in Lazarus. |
|
I found that reassigning all nodes by TTreeNode.Text := UTF8toANSI(TTreeNode.Text) will help to sort alphabetically. After sort you can reassign TTreeNode.Text back. |
|
> I can patch treeview.inc , but in new installer this problem will come back. > So can you patch installer ? This makes no sense to me. If I change the implementation of TCustomTreeView.DefaultTreeViewSort in trunk, it will apply in 1.2 release or next fix of 1.0 branch if this wil be merged. The installer has nothing to do with it. > I found that reassigning all nodes by TTreeNode.Text := UTF8toANSI(TTreeNode.Text) > will help to sort alphabetically. > After sort you can reassign TTreeNode.Text back. This will fail with any Unicode Character outside your current codepage. |
|
Please close if OK. |
|
Thank you very much. |
Date Modified | Username | Field | Change |
---|---|---|---|
2013-07-13 17:44 | Anna | New Issue | |
2013-07-13 17:44 | Anna | File Added: Cyrillic_Alphasort_.zip | |
2013-07-13 17:46 | Anna | Note Added: 0068832 | |
2013-07-13 17:46 | Anna | Note Edited: 0068832 | View Revisions |
2013-07-13 18:34 | Bart Broersma | Note Added: 0068833 | |
2013-07-13 19:22 | Anna | Note Added: 0068834 | |
2013-07-13 19:23 | Anna | Note Edited: 0068834 | View Revisions |
2013-07-13 19:30 | Anna | Note Edited: 0068834 | View Revisions |
2013-07-13 19:30 | Anna | Note Edited: 0068834 | View Revisions |
2013-07-13 20:37 | Anton | Note Added: 0068836 | |
2013-07-13 20:45 | Anton | Note Added: 0068837 | |
2013-07-13 21:34 | Avishai | Note Added: 0068838 | |
2013-07-14 05:40 | Anna | Note Added: 0068841 | |
2013-07-14 11:48 | Bart Broersma | Note Added: 0068846 | |
2013-07-14 11:48 | Bart Broersma | Assigned To | => Bart Broersma |
2013-07-14 11:48 | Bart Broersma | Status | new => assigned |
2013-07-17 23:23 | Bart Broersma | Fixed in Revision | => r42123 |
2013-07-17 23:23 | Bart Broersma | LazTarget | => - |
2013-07-17 23:23 | Bart Broersma | Note Added: 0068920 | |
2013-07-17 23:23 | Bart Broersma | Status | assigned => resolved |
2013-07-17 23:23 | Bart Broersma | Fixed in Version | => 1.1 (SVN) |
2013-07-17 23:23 | Bart Broersma | Resolution | open => fixed |
2013-07-24 14:59 | Anna | Note Added: 0069072 | |
2013-07-24 14:59 | Anna | Status | resolved => closed |