3 <<mbstowcs>>---minimal multibyte string to wide char converter
10 int mbstowcs(wchar_t *restrict <[pwc]>, const char *restrict <[s]>, size_t <[n]>);
13 When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming
14 implementation of <<mbstowcs>>. In this case, the
15 only ``multi-byte character sequences'' recognized are single bytes,
16 and they are ``converted'' to wide-char versions simply by byte
19 When _MB_CAPABLE is defined, this routine calls <<_mbstowcs_r>> to perform
20 the conversion, passing a state variable to allow state dependent
21 decoding. The result is based on the locale setting which may
22 be restricted to a defined set of locales.
25 This implementation of <<mbstowcs>> returns <<0>> if
26 <[s]> is <<NULL>> or is the empty string;
27 it returns <<-1>> if _MB_CAPABLE and one of the
28 multi-byte characters is invalid or incomplete;
29 otherwise it returns the minimum of: <<n>> or the
30 number of multi-byte characters in <<s>> plus 1 (to
31 compensate for the nul character).
32 If the return value is -1, the state of the <<pwc>> string is
33 indeterminate. If the input has a length of 0, the output
34 string will be modified to contain a wchar_t nul terminator.
37 <<mbstowcs>> is required in the ANSI C standard. However, the precise
38 effects vary with the locale.
40 <<mbstowcs>> requires no supporting OS subroutines.
50 mbstowcs (wchar_t *__restrict pwcs
,
51 const char *__restrict s
,
58 return _mbstowcs_r (_REENT
, pwcs
, s
, n
, &state
);
59 #else /* not _MB_CAPABLE */
65 if ((*pwcs
++ = (wchar_t) *s
++) == 0)
72 #endif /* not _MB_CAPABLE */
75 #endif /* !_REENT_ONLY */