Стандарт языка Си С99 TC (1113411), страница 71
Текст из файла (страница 71)
The initialwide character of s2 overwrites the null wide character at the end of s1.Returns3The wcscat function returns the value of s1.7.24.4.3.2 The wcsncat functionSynopsis1#include <wchar.h>wchar_t *wcsncat(wchar_t * restrict s1,const wchar_t * restrict s2,size_t n);Description2The wcsncat function appends not more than n wide characters (a null wide characterand those that follow it are not appended) from the array pointed to by s2 to the end of378Library§7.24.4.3.2WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3the wide string pointed to by s1.
The initial wide character of s2 overwrites the nullwide character at the end of s1. A terminating null wide character is always appended tothe result.298)Returns3The wcsncat function returns the value of s1.7.24.4.4 Wide string comparison functions1Unless explicitly stated otherwise, the functions described in this subclause order twowide characters the same way as two integers of the underlying integer type designatedby wchar_t.7.24.4.4.1 The wcscmp functionSynopsis1#include <wchar.h>int wcscmp(const wchar_t *s1, const wchar_t *s2);Description2The wcscmp function compares the wide string pointed to by s1 to the wide stringpointed to by s2.Returns3The wcscmp function returns an integer greater than, equal to, or less than zero,accordingly as the wide string pointed to by s1 is greater than, equal to, or less than thewide string pointed to by s2.7.24.4.4.2 The wcscoll functionSynopsis1#include <wchar.h>int wcscoll(const wchar_t *s1, const wchar_t *s2);Description2The wcscoll function compares the wide string pointed to by s1 to the wide stringpointed to by s2, both interpreted as appropriate to the LC_COLLATE category of thecurrent locale.Returns3The wcscoll function returns an integer greater than, equal to, or less than zero,accordingly as the wide string pointed to by s1 is greater than, equal to, or less than the298) Thus, the maximum number of wide characters that can end up in the array pointed to by s1 iswcslen(s1)+n+1.§7.24.4.4.2Library379ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256wide string pointed to by s2 when both are interpreted as appropriate to the currentlocale.7.24.4.4.3 The wcsncmp functionSynopsis1#include <wchar.h>int wcsncmp(const wchar_t *s1, const wchar_t *s2,size_t n);Description2The wcsncmp function compares not more than n wide characters (those that follow anull wide character are not compared) from the array pointed to by s1 to the arraypointed to by s2.Returns3The wcsncmp function returns an integer greater than, equal to, or less than zero,accordingly as the possibly null-terminated array pointed to by s1 is greater than, equalto, or less than the possibly null-terminated array pointed to by s2.7.24.4.4.4 The wcsxfrm functionSynopsis1#include <wchar.h>size_t wcsxfrm(wchar_t * restrict s1,const wchar_t * restrict s2,size_t n);Description2The wcsxfrm function transforms the wide string pointed to by s2 and places theresulting wide string into the array pointed to by s1.
The transformation is such that ifthe wcscmp function is applied to two transformed wide strings, it returns a value greaterthan, equal to, or less than zero, corresponding to the result of the wcscoll functionapplied to the same two original wide strings. No more than n wide characters are placedinto the resulting array pointed to by s1, including the terminating null wide character. Ifn is zero, s1 is permitted to be a null pointer.Returns3The wcsxfrm function returns the length of the transformed wide string (not includingthe terminating null wide character).
If the value returned is n or greater, the contents ofthe array pointed to by s1 are indeterminate.4EXAMPLE The value of the following expression is the length of the array needed to hold thetransformation of the wide string pointed to by s:380Library§7.24.4.4.4WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC31 + wcsxfrm(NULL, s, 0)7.24.4.4.5 The wmemcmp functionSynopsis1#include <wchar.h>int wmemcmp(const wchar_t *s1, const wchar_t *s2,size_t n);Description2The wmemcmp function compares the first n wide characters of the object pointed to bys1 to the first n wide characters of the object pointed to by s2.Returns3The wmemcmp function returns an integer greater than, equal to, or less than zero,accordingly as the object pointed to by s1 is greater than, equal to, or less than the objectpointed to by s2.7.24.4.5 Wide string search functions7.24.4.5.1 The wcschr functionSynopsis1#include <wchar.h>wchar_t *wcschr(const wchar_t *s, wchar_t c);Description2The wcschr function locates the first occurrence of c in the wide string pointed to by s.The terminating null wide character is considered to be part of the wide string.Returns3The wcschr function returns a pointer to the located wide character, or a null pointer ifthe wide character does not occur in the wide string.7.24.4.5.2 The wcscspn functionSynopsis1#include <wchar.h>size_t wcscspn(const wchar_t *s1, const wchar_t *s2);Description2The wcscspn function computes the length of the maximum initial segment of the widestring pointed to by s1 which consists entirely of wide characters not from the widestring pointed to by s2.§7.24.4.5.2Library381ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256Returns3The wcscspn function returns the length of the segment.7.24.4.5.3 The wcspbrk functionSynopsis1#include <wchar.h>wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2);Description2The wcspbrk function locates the first occurrence in the wide string pointed to by s1 ofany wide character from the wide string pointed to by s2.Returns3The wcspbrk function returns a pointer to the wide character in s1, or a null pointer ifno wide character from s2 occurs in s1.7.24.4.5.4 The wcsrchr functionSynopsis1#include <wchar.h>wchar_t *wcsrchr(const wchar_t *s, wchar_t c);Description2The wcsrchr function locates the last occurrence of c in the wide string pointed to bys.
The terminating null wide character is considered to be part of the wide string.Returns3The wcsrchr function returns a pointer to the wide character, or a null pointer if c doesnot occur in the wide string.7.24.4.5.5 The wcsspn functionSynopsis1#include <wchar.h>size_t wcsspn(const wchar_t *s1, const wchar_t *s2);Description2The wcsspn function computes the length of the maximum initial segment of the widestring pointed to by s1 which consists entirely of wide characters from the wide stringpointed to by s2.Returns3The wcsspn function returns the length of the segment.382Library§7.24.4.5.5WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC37.24.4.5.6 The wcsstr functionSynopsis1#include <wchar.h>wchar_t *wcsstr(const wchar_t *s1, const wchar_t *s2);Description2The wcsstr function locates the first occurrence in the wide string pointed to by s1 ofthe sequence of wide characters (excluding the terminating null wide character) in thewide string pointed to by s2.Returns3The wcsstr function returns a pointer to the located wide string, or a null pointer if thewide string is not found.
If s2 points to a wide string with zero length, the functionreturns s1.7.24.4.5.7 The wcstok functionSynopsis1#include <wchar.h>wchar_t *wcstok(wchar_t * restrict s1,const wchar_t * restrict s2,wchar_t ** restrict ptr);Description2A sequence of calls to the wcstok function breaks the wide string pointed to by s1 intoa sequence of tokens, each of which is delimited by a wide character from the wide stringpointed to by s2. The third argument points to a caller-provided wchar_t pointer intowhich the wcstok function stores information necessary for it to continue scanning thesame wide string.3The first call in a sequence has a non-null first argument and stores an initial value in theobject pointed to by ptr.
Subsequent calls in the sequence have a null first argument andthe object pointed to by ptr is required to have the value stored by the previous call inthe sequence, which is then updated. The separator wide string pointed to by s2 may bedifferent from call to call.4The first call in the sequence searches the wide string pointed to by s1 for the first widecharacter that is not contained in the current separator wide string pointed to by s2. If nosuch wide character is found, then there are no tokens in the wide string pointed to by s1and the wcstok function returns a null pointer. If such a wide character is found, it isthe start of the first token.5The wcstok function then searches from there for a wide character that is contained inthe current separator wide string.
If no such wide character is found, the current token§7.24.4.5.7Library383ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256extends to the end of the wide string pointed to by s1, and subsequent searches in thesame wide string for a token return a null pointer. If such a wide character is found, it isoverwritten by a null wide character, which terminates the current token.6In all cases, the wcstok function stores sufficient information in the pointer pointed toby ptr so that subsequent calls, with a null pointer for s1 and the unmodified pointervalue for ptr, shall start searching just past the element overwritten by a null widecharacter (if any).Returns7The wcstok function returns a pointer to the first wide character of a token, or a nullpointer if there is no token.8EXAMPLE#include <wchar.h>static wchar_t str1[] = L"?a???b,,,#c";static wchar_t str2[] = L"\t \t";wchar_t *t, *ptr1, *ptr2;ttttt=====wcstok(str1,wcstok(NULL,wcstok(str2,wcstok(NULL,wcstok(NULL,L"?", &ptr1);L",", &ptr1);L" \t", &ptr2);L"#,", &ptr1);L"?", &ptr1);//////////tttttpoints to the token L"a"points to the token L"??b"is a null pointerpoints to the token L"c"is a null pointer7.24.4.5.8 The wmemchr functionSynopsis1#include <wchar.h>wchar_t *wmemchr(const wchar_t *s, wchar_t c,size_t n);Description2The wmemchr function locates the first occurrence of c in the initial n wide characters ofthe object pointed to by s.Returns3The wmemchr function returns a pointer to the located wide character, or a null pointer ifthe wide character does not occur in the object.384Library§7.24.4.5.8WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC37.24.4.6 Miscellaneous functions7.24.4.6.1 The wcslen functionSynopsis1#include <wchar.h>size_t wcslen(const wchar_t *s);Description2The wcslen function computes the length of the wide string pointed to by s.Returns3The wcslen function returns the number of wide characters that precede the terminatingnull wide character.7.24.4.6.2 The wmemset functionSynopsis1#include <wchar.h>wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n);Description2The wmemset function copies the value of c into each of the first n wide characters ofthe object pointed to by s.Returns3The wmemset function returns the value of s.7.24.5 Wide character time conversion functions7.24.5.1 The wcsftime functionSynopsis1#include <time.h>#include <wchar.h>size_t wcsftime(wchar_t * restrict s,size_t maxsize,const wchar_t * restrict format,const struct tm * restrict timeptr);Description2The wcsftime function is equivalent to the strftime function, except that:— The argument s points to the initial element of an array of wide characters into whichthe generated output is to be placed.§7.24.5.1Library385ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256— The argument maxsize indicates the limiting number of wide characters.— The argument format is a wide string and the conversion specifiers are replaced bycorresponding sequences of wide characters.— The return value indicates the number of wide characters.Returns3If the total number of resulting wide characters including the terminating null widecharacter is not more than maxsize, the wcsftime function returns the number ofwide characters placed into the array pointed to by s not including the terminating nullwide character.