Belongs to : Function


The AnsiCompareStr function compares String1 and String2 for equality.

This is the modern, Locale safe form of CompareStr.

All Ansi commands support multi-byte and accented characters.

It returns these values :

String1 < String2     : -ve number
String1 = String2     : 0
String1 > String2     : +ve number

The comparison is not affected by length – it is carried out on a letter by letter basis. But a longer string is greater than a shorter, otherwise matching string.

The comparison is case sensitive.

In Delphi :

Upper case letters > Lower case letters
Lower case letters > Numbers

Multi-byte character sets are operating system defined. For example, Oriental versions of Windows uses multi-byte characters to support their very large set of primitives ('letters').

Example code