compare_strings


template <class character>
int compare_strings(const character* s1,
                    const character* s2)

This function compares two strings.

Parameters

const character* s1

A pointer to the first string to participate in the comparison.

const character* s2

A pointer to the second string to participate in the comparison.

Return

int

<0 The first string is less than the second string.
0 The strings are equal.
>0 The first string is greater than the second string.

Notes

This function compares two strings by examining successive characters until an inequality is found or the end of the strings is reached. The value returned is the difference of the values of the first unequal characters that are encountered. For example, when comparing "abch" and "abcdefg" the difference of h and d is returned. The computed difference depends upon the language codepage (locale) being used.

The language (locale) selected by the user at setup time or via the control panel determines which string is greater (or whether the strings are the same). If no locale is selected, the comparison is performed using default locale values. For the default locale, uppercase characters have lower values than lowercase characters.

double byte strings may be compared by the wide version of this function.

This function uses a word sort rather than a string sort. A word sort treats hyphens and apostrophes differently than it treats other non-alphanumeric symbols. This is done to ensure ensure that words such as "coop" and "co-op" stay together within a sorted list.

This function calls the function compare_strings_via_locale, supplying the default locale in the process.