HP-UX Reference (11i v3 07/02) - 3 Library Functions N-Z (vol 7)
s
string(3C) string(3C)
strxfrm() offers better performance in, for example, a sorting routine where a number of strings are
each transformed just once and the transformed versions are compared against each other many times.
EXTERNAL INFLUENCES
Locale
The LC_CTYPE category determines the interpretation of the bytes within the string arguments to the
strcoll() and strxfrm() functions as single and/or multibyte characters. It also determines the
case conversions to be done for the
strcasecmp() and strncasecmp() functions.
The
LC_COLLATE category determines the collation ordering used by the
strcoll() and strxfrm()
functions.
International Code Set Support
Single- and multibyte character code sets are supported for the
strcoll() and strxfrm() functions.
All other functions support only single-byte character code sets.
EXAMPLES
The following sample piece of code finds the tokens, separated by blanks, that are in the string s (assuming
that there are at most
MAXTOK tokens):
int i = 0;
char *s, *last, *tok[MAXTOK];
tok[0] = strtok_r(s, " ", &last);
while (tok[++i] = strtok_r(NULL, " ", &last));
WARNINGS
The functions strcat(), strncat(), strcpy(), strncpy(), strtok(), and strtok_r()
alter the contents of the array to which s1 points. They do not check for overflow of the array.
Null pointers for destination strings cause undefined behavior.
Character movement is performed differently in different implementations, so moves involving overlapping
source and destination strings may yield surprises.
The transformed string produced by strxfrm() for a language using an 8-bit code set is usually at least
twice as large as the original string and may be as much four times as large (ordinary characters occupy
two bytes each in the transformed string, 1-to-2 characters four bytes, 2-to-1 characters two bytes per origi-
nal pair, and don’t-care characters no bytes). Each character of a multibyte code set (Asian languages)
occupies three bytes in the transformed string.
For functions strcoll() and strxfrm() results are undefined if the languages specified by the
LC_COLLATE and LC_CTYPE categories use different code sets.
Users of strtok_r() should also note that the prototype of this function will change in the next release
for conformance with the new POSIX Threads standard.
AUTHOR
string() was developed by the University of California, Berkeley, AT&T, OSF, and HP.
SEE ALSO
conv(3C), malloc(3C), memory(3C), setlocale(3C), thread_safety(5), glossary(9).
STANDARDS CONFORMANCE
strcat(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
strchr(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
strcmp(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
strcoll(): AES, SVID3, XPG3, XPG4, ANSI C
strcpy(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
strcspn(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
strdup(): SVID2, SVID3
strlen(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
480 Hewlett-Packard Company − 3 − HP-UX 11i Version 3: February 2007