DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

strcoll(S)


strcoll, strncoll, strnxfrm, strxfrm -- handles collation of strings

Syntax

cc . . . -lc

#include <string.h>

int strcoll (str1, str2) char *str1, *str2;

int strncoll (str1, str2, n) char *str1, *str2; int n;

int strnxfrm (to, from, maxsize, n) char *to, *from; int maxsize, n;

int strxfrm (to, from, maxsize) char *to, *from; int maxsize;

Description

These functions operate on null-terminated strings.

The strxfrm routine transforms the string from according to the collation environment of the current locale. The result is placed in the character array to. The maximum size of the resulting string is the value contained in the maxsize variable. The result can then be compared with another transformed string to establish the collating order of the two original strings. The strnxfrm routine transforms at most n characters in the from string, where n is defined after the following collation rules have been applied:

Both functions return the size of the array required to hold the transformed string. If the return value is greater than maxsize then the contents of to is undefined.

The strcoll function is used to collate the two strings str1 and str2 according to the collation environment of the current locale. The returned value is equal to, less than or greater than 0, according to whether str1 is equal to, less than or greater than str2. strncoll collates the two strings until the nth character in str1 is reached. The nth character is defined in the same way as strnxfrm.

See also

coltbl(M), nl_strcmp(S), string(S)

Standards conformance

strcoll and strxfrm are conformant with:

ANSI X3.159-1989 Programming Language -- C .

Examples

It is assumed that the value of maxsize is large enough to contain the transformed string in the strxfrm and the strnxfrm examples.

Example 1:
This is an example of the strxfrm routine:
   char *to1, *to2;
   int ret;
   

strxfrm(to1, "Straße", maxsize); strxfrm(to2, "Strasse", maxsize); ret= strcmp(to1, to2)

ret contains 0 becaues "Straße" and "Strasse" collate as equal.

Example 2:
This is an example of the strcoll routine:
   int ret;
   

ret = strcoll("Straße", "Strasse");

ret contains 0 because "Straße" and "Strasse" collate as equal.

Example 3:
This is an example of the strnxfrm routine:
   char *to;
   

strnxfrm(to, "Straße", maxsize, 6);

This transforms only the "Straß" portion of the string, as ß counts as two characters.

Example 4:
This is an example of the strncoll routine:
   strncoll("Straße", "Bahn", 6);
This compares only the "Straß" portion of the string, as ß counts as two characters.

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003