Substring.CompareInvariant Method

Overload List

#SignatureDescription
1class function CompareInvariant(const StrA: string; const IndexA: Integer; const StrB: string; const IndexB, Length: Integer; const IgnoreCase: Boolean): Integer; overload; static;
2class function CompareInvariant(const StrA, StrB: string; const IgnoreCase: Boolean): Integer; overload; static;Compares StrA with StrB, or Length characters of each from IndexA and IndexB (0-based), by UTF-16 code unit; IgnoreCase True ignores case by the operating system's uppercase table, the same under every locale.

Overload 1: class function CompareInvariant(const StrA: string; const IndexA: Integer; const StrB: string; const IndexB, Length: Integer; const IgnoreCase: Boolean): Integer; overload; static;

#NameTypeDescription
1StrAstring
2IndexAInteger
3StrBstring
4IndexBInteger
5LengthInteger
6IgnoreCaseBoolean

Returns: Integer

Overload 2: class function CompareInvariant(const StrA, StrB: string; const IgnoreCase: Boolean): Integer; overload; static;

Compares StrA with StrB, or Length characters of each from IndexA and IndexB (0-based), by UTF-16 code unit; IgnoreCase True ignores case by the operating system's uppercase table, the same under every locale.

#NameTypeDescription
1StrAstring
2StrBstring
3IgnoreCaseBoolean

Returns: Integer - 0 when equal, else the difference of the first differing pair, in upper case when IgnoreCase is True, or of the lengths when one text is a prefix of the other.

Remarks:

Every text kind, both texts of one kind. A window outside its text raises ESubstringRangeError. Note: This routine is 8.0 to 45 times slower than CompareAscii due to the operating system's case table. Use CompareAscii, if A to Z is enough.

Examples

Accented letters in either case.

uses Substr;

procedure Example;
begin
    Assert(Substring.CompareInvariant('ab'#$E9, 'AB'#$C9, True) = 0);
end;
See Also: Substring.CompareAscii, Substring.CompareAscii, Substring.CompareLinguistic, Substring.CompareLinguistic, Substring.CompareLinguistic, Substring.CompareLinguistic, Substring.CompareLinguistic, Substring.CompareLinguistic, Substring.CompareLinguistic, Substring.CompareLinguistic, Substring.CompareLinguistic, Substring.CompareLinguistic, Substring.CompareLinguistic, Substring.CompareLinguistic