STRXFRM - transform string for comparison.

(ANSI Standard)

Usage:

#include <string.h>
length = strxfrm(modstr,orig,N);

Where:

char *modstr;
points to an area of memory where the transformed string may be placed. This must be at least N characters long.
const char *orig;
points to the string you want to transform.
size_t N;
is the maximum number of characters that should be transformed.
size_t length;
is the length of the transformed string.

Description:

The "strxfrm" function converts a string into a form that might be called the "lowest common denominator" in the current locale. If "orig1" and "orig2" are transformed into "modstr1" and "modstr2" using "strxfrm", then the result of

strcmp(modstr1,modstr2)

is equal to the result of

strcoll(orig1,orig2)

As an example, suppose that in a particular locale, "strcoll" uses a collating sequence where uppercase letters compare equal to lowercase ones. Then "strxfrm" might convert all letters in all strings into lowercase. In this way, if the original strings compare equal with "strcoll" (which ignores case distinction), the transformed strings will compare equal with "strcmp" (because all letters in the transformed strings are in the same case).

The "strxfrm" function stops converting characters when it encounters a '\0' or when it has stored N characters in *modstr. The result of "strxfrm" is the length of the transformed string, not counting any '\0' at the end.

The "modstr" argument need not have the same number of characters as "orig". There may not be a way to derive the original "orig" string from the resulting "modstr". If "modstr" and "orig" overlap, the behavior is undefined.

If N is zero, "modstr" may be NULL; in this case, "strxfrm" returns the number of bytes needed to hold the transformed "orig" (not counting the '\0' on the end).

See Also:

expl c lib strcmp

expl c lib strcoll

Copyright © 1996, Thinkage Ltd.