Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mbsrtowcs(3) [osf1 man page]

mbstowcs(3)						     Library Functions Manual						       mbstowcs(3)

NAME
mbstowcs, mbsrtowcs - Converts a multibyte character string to a wide-character string LIBRARY
Standard C Library (libc) SYNOPSIS
#include <stdlib.h> size_t mbstowcs( wchar_t *pwcs, const char *s, size_t n); #include <wchar.h> size_t mbsrtowcs( wchar_t *pwcs, const char **s, size_t n, mbstate_t *ps ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: mbstowcs(), mbsrtowcs(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to the array where the result of the conversion is stored. Points or indirectly points to the multibyte-character string to be con- verted. Specifies the number of wide characters in the destination array. Points to an mbstate_t structure containing the conversion state of the data in s. DESCRIPTION
The mbstowcs() function converts a multibyte-character string into a wide-character string, which is stored at a specified location. The function does not examine or convert any characters that follow a null byte, which is converted and stored as a wide-character code with value zero. The function does not store more than n wide characters in pwcs. When operating on overlapping strings, the behavior of this function is undefined. Behavior of the mbstowcs() function is affected by the LC_CTYPE category of the current locale. In locales that use shift-state encoding, the array pointed to by the s parameter begins in the initial shift state. The mbsrtowcs() function is a restartable version of mbstowcs(). Restartable conversion functions obtain and store the conversion state in an mbstate_t structure that can be read and changed by subsequent calls to the same or other restartable conversion functions. RESTRICTIONS
[Tru64 UNIX] The mbsrtowcs() and other restartable versions of conversion functions are functional only when used with locales that sup- port shift-state encoding. Currently, the operating system does not provide any locales that support shift-state encoding, so the mbstowcs() and mbsrtowcs() functions do not differ in terms of run-time behavior. RETURN VALUES
When the mbstowcs() and mbsrtowcs() functions encounter an invalid multibyte character during conversion, they return a value of -1 cast to size_t and set errno to indicate the error. Otherwise: The mbstowcs() function returns the number of characters stored in the output array (or required if pwcs is null), not including a terminating null wide character, if any. When the return value is n, the output array is not null-terminated. The mbsrtowcs() function returns the number of characters stored in the output array, not including a terminating null wide character, if any. ERRORS
If the following condition occurs, the mbstowcs() and mbsrtowcs() functions set errno to the corresponding value: The s parameter contains an invalid multibyte character. RELATED INFORMATION
Functions: btowc(3), mblen(3), mbsinit(3), mbtowc(3), wcstombs(3), wcslen(3), wctob(3), wctomb(3) delim off mbstowcs(3)

Check Out this Related Man Page

MBSTOWCS(3)						     Linux Programmer's Manual						       MBSTOWCS(3)

NAME
mbstowcs - convert a multibyte string to a wide-character string SYNOPSIS
#include <stdlib.h> size_t mbstowcs(wchar_t *dest, const char *src, size_t n); DESCRIPTION
If dest is not a NULL pointer, the mbstowcs() function converts the multibyte string src to a wide-character string starting at dest. At most n wide characters are written to dest. The conversion starts in the initial state. The conversion can stop for three reasons: 1. An invalid multibyte sequence has been encountered. In this case (size_t) -1 is returned. 2. n non-L'' wide characters have been stored at dest. In this case the number of wide characters written to dest is returned, but the shift state at this point is lost. 3. The multibyte string has been completely converted, including the terminating null wide character (''). In this case the number of wide characters written to dest, excluding the terminating null wide character, is returned. The programmer must ensure that there is room for at least n wide characters at dest. If dest is NULL, n is ignored, and the conversion proceeds as above, except that the converted wide characters are not written out to mem- ory, and that no length limit exists. In order to avoid the case 2 above, the programmer should make sure n is greater or equal to mbstowcs(NULL,src,0)+1. RETURN VALUE
The mbstowcs() function returns the number of wide characters that make up the converted part of the wide-character string, not including the terminating null wide character. If an invalid multibyte sequence was encountered, (size_t) -1 is returned. CONFORMING TO
C99. NOTES
The behavior of mbstowcs() depends on the LC_CTYPE category of the current locale. The function mbsrtowcs(3) provides a better interface to the same functionality. SEE ALSO
mbsrtowcs(3), wcstombs(3) COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2011-09-28 MBSTOWCS(3)
Man Page