wstring(3W) — MISC. REFERENCE MANUAL PAGES
NAME
wstring: wscat, wsncat, wscmp, wsncmp, wscpy, wsncpy, wslen, wschr, wsrchr, wspbrk, wsspn, wscspn, wstok, wstostr, strtows − wchar_t string operations and type transformation
SYNOPSIS
#include <widec.h> wchar_t ∗wscat(wchar_t ∗s1, wchar_t ∗s2); wchar_t ∗wsncat(wchar_t ∗s1, wchar_t ∗s2, int n); int wscmp(wchar_t ∗s1, wchar_t ∗s2); int wsncmp(wchar_t ∗s1, wchar_t ∗s2, int n); wchar_t ∗wscpy(wchar_t ∗s1, wchar_t ∗s2); wchar_t ∗wsncpy(wchar_t ∗s1, wchar_t ∗s2, int n); int wslen(wchar_t ∗s); wchar_t ∗wschr(wchar_t ∗s, int c); wchar_t ∗wsrchr(wchar_t ∗s, int c); wchar_t ∗wspbrk(wchar_t ∗s1, wchar_t ∗s2); int wsspn(wchar_t ∗s1, wchar_t ∗s2); int wscspn(wchar_t ∗s1, wchar_t ∗s2); wchar_t ∗wstok(wchar_t ∗s1, wchar_t ∗s2); char ∗wstostr(char ∗s1, wchar_t ∗s2); wchar_t ∗strtows(wchar_t ∗s1, char ∗s2);
DESCRIPTION (International Functions)
The arguments s1, s2 and s point to wchar_t strings (that is, arrays of wchar_t characters terminated by a wchar_t null character). The functions wscat(), wsncat(), wscpy() and wsncpy() all modify s1. These functions do not check for an overflow condition of the array pointed to by s1.
wscat() appends a copy of the wchar_t string s2 to the end of the wchar_t string s1. wsncat() appends at most n wchar_t characters. Each function returns s1.
wscmp() compares its arguments and returns an integer less than, equal to, or greater than 0, depending on whether s1 is less than, equal to, or greater than s2. wsncmp() makes the same comparison but looks at most n wchar_t characters.
wscpy() copies wchar_t string s2 to s1, stopping after the wchar_t null character has been copied. wsncpy() copies exactly n wchar_t characters, truncating s2 or adding wchar_t null characters to s1, if necessary. The result will not be wchar_t null-terminated if the length of s2 is n or more. Each function returns s1.
wslen() returns the number of wchar_t characters in s, not includng the termnating wchar_t null character.
wschr() [wsrchr()] returns a pointer to the first [last] occurrence of wchar_t character c in wchar_t string s, or a null pointer, if c does not occur in the string. The wchar_t null character terminating a string is considered to be part of the string.
wspbrk() returns a pointer to the first occurrence in wchar_t string s1 of any wchar_t character from wchar_t string s2, or a null pointer if there is no wchar_t character from s2 in s1.
wsspn() [wscspn()] returns the length of the initial segment of wchar_t string s1, which consists [does not consist] entirely of wchar_t characters from wchar_t string s2.
wstok() considers the wchar_t string s1 to consist of a sequence of zero or more text tokens, separated by spans of one or more wchar_t characters from the separator wchar_t string s2. The first call (with the pointer s1 specified) returns a pointer to the first wchar_t character of the first token, and writes a wchar_t null character into s1 immediately following the returned token. The function keeps track of its position in the wchar_t string between separate calls, so that subsequent calls (which must be made with the first argument a null pointer) will progress through the wchar_t string s1 immediately following that token. Similarly, subsequent calls will progress through the wchar_t string s1 until no tokens remain. The wchar_t separator string s2 may be different from call to call. A null pointer is returned when no token remains in s1.
wstostr() transforms wchar_t characters in wchar_t string s2 into EUC, and transfers them to character string s1, stopping after the wchar_t null character has been processed.
strtows() transforms EUC in character string s2 into the wchar_t characters, and transfers those to wchar_t string s1, stopping after the null character has been processed.
DIAGNOSTICS
On success, wstostr() and strtows() return s1. If an illegal byte sequence is detected, a null pointer is returned and EILSEQ is set to errno.