delphi 的comparetext比较汉字?
虎滴小猪猪 2010-05-28 03:18:16 compareText在比较汉字时,是按照A-Z的顺序比较的吗?
那遇到多音字呢,
我现在用的是TListView的
//ListView排序的回调函数,默认的是快速排序法,也可以自己在这里做算法
function CustomSortProc(Item1, Item2: TListItem; ParamSort: integer): integer; stdcall;
var txt1,txt2 : string;
begin
if ParamSort <> 0 then
begin
txt1 := Item1.SubItems.Strings[ParamSort - 1];
txt2 := Item2.SubItems.Strings[ParamSort - 1];
if m_bSort then
begin
Result := CompareText(txt1,txt2);
end
else
begin
Result := -CompareText(txt1,txt2);
end;
end
else
begin
if m_bSort then
begin
Result := CompareText(Item1.Caption,Item2.Caption);
end
else
begin
Result := -CompareText(Item1.Caption,Item2.Caption);
end;
end;
end;
发现排序后,有一些汉字的名字,排在z后边了。不知道为啥?