Manual Page Result
0
Command: mbstowcs | Section: 3 | Source: Digital UNIX | File: mbstowcs.3.gz
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.so, libc.a)
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 stan-
dards as follows:
mbstowcs(): ISO C, XPG4
mbsrtowcs(): ISO C
Refer to the standards(5) reference page for more information about in-
dustry 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
converted. 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 cate-
gory 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
The mbsrtowcs() and other restartable versions of conversion functions
are functional only when used with locales that support shift-state en-
coding. Currently, the DIGITAL UNIX product does not provide any lo-
cales that support shift-state encoding, so the mbstowcs() and mbsr-
towcs() 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, these func-
tions return the number of wide characters stored in the output array,
not including a terminating null wide character. (When the return value
is n, the output array is not null-terminated.)
ERRORS
If the following condition occurs, the mbstowcs() and mbsrtowcs() func-
tions 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), wc-
slen(3), wctob(3), wctomb(3) delim off
mbstowcs(3)