cs_strcmp

Description

Compares two strings using a specified sort order.

Syntax

CS_RETCODE cs_strcmp(context, locale, type, str1,
               len1, str2, len2, result)
 
 CS_CONTEXT    *context;
 CS_LOCALE       *locale;
 CS_INT               type;
 CS_CHAR           *str1;
 CS_INT               len1;
 CS_CHAR           *str2;
 CS_INTl              len2;
 CS_INT               *result;

Parameters

context

A pointer to a CS_CONTEXT structure.

locale

A pointer to a CS_LOCALE structure. A CS_LOCALE structure contains locale information, including the collating sequence that cs_strcmp uses to define a sort order.

An application can call cs_locale with type as CS_LC_COLLATE or CS_SYB_SORTORDER to change the collating sequence in a CS_LOCALE structure.

locale can be NULL. If locale is NULL, cs_strcmp uses whatever localization information is defined in the context CS_CONTEXT structure. Localization information is always defined at the context level, because a CS_CONTEXT picks up default localization information when it is allocated.

type

The type of comparison to perform.

If type is CS_COMPARE, cs_strcmp performs a lexicographic comparison.

If type is CS_SORT, the values are compared as they would appear in a sorted list. It is possible for strings that are lexicographically equal to belong in different places in a sorted list.

str1

A pointer to the first string for the comparison.

len1

The length, in bytes, of *str1. If *str1 is null-terminated, pass len1 as CS_NULLTERM.

str2

A pointer to the second string for the comparison.

len2

The length, in bytes, of *str2. If *str2 is null-terminated, pass len2 as CS_NULLTERM.

result

A pointer to the result of the comparison. The following table lists the possible values for *result:

Value of *result

Indicates

<0

str1 is lexicographically less than str2, or str1 appears before str2 in a sorted list.

0

str1 is lexicographically equal to str1, or str1 is identical to str2.

>0

str1 is lexicographically greater than str2, or str1 appears after str2 in a sorted list.

Returns

cs_strcmp returns:

Returns

Indicates

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

Usage

See also

cs_cmp, cs_locale, cs_config