|
|
#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;
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:
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.
ANSI X3.159-1989 Programming Language -- C .
char *to1, *to2; int ret;ret contains 0 becaues "Straße" and "Strasse" collate as equal.strxfrm(to1, "Straße", maxsize); strxfrm(to2, "Strasse", maxsize); ret= strcmp(to1, to2)
int ret;ret contains 0 because "Straße" and "Strasse" collate as equal.ret = strcoll("Straße", "Strasse");
char *to;This transforms only the "Straß" portion of the string, as ß counts as two characters.strnxfrm(to, "Straße", maxsize, 6);
strncoll("Straße", "Bahn", 6);This compares only the "Straß" portion of the string, as ß counts as two characters.