UTF8CompareLatinTextFast might return wrong results
- Lazarus Version: 2.3
This may also affect TStringListUTF8Fast. As soon as the binary search (in TStrings) is compromised incorrect index are to be expected.
The below program claims that b > a
and a > c
Then it must be that b > c
Yet the program says that b < c
. That is not possible.
Using this in any "sort" or "bin-search" can lead to problems....
program Project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
Classes, LazUTF8
{ you can add units after this };
{$R *.res}
var
a,b,c: string;
begin
a := 'abcä';
b := 'abcx';
c := 'abc|';
writeln( UTF8CompareLatinTextFast(a,b) ); // -1 a < b or b greater than a
writeln( UTF8CompareLatinTextFast(a,c) ); // 1 a > c
writeln( UTF8CompareLatinTextFast(b,c) ); // -4 b < c
readln;
end.