3 <<wctomb>>---minimal wide char to multibyte converter
10 int wctomb(char *<[s]>, wchar_t <[wchar]>);
13 When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming
14 implementation of <<wctomb>>. The
15 only ``wide characters'' recognized are single bytes,
16 and they are ``converted'' to themselves.
18 When _MB_CAPABLE is defined, this routine calls <<_wctomb_r>> to perform
19 the conversion, passing a state variable to allow state dependent
20 decoding. The result is based on the locale setting which may
21 be restricted to a defined set of locales.
23 Each call to <<wctomb>> modifies <<*<[s]>>> unless <[s]> is a null
24 pointer or _MB_CAPABLE is defined and <[wchar]> is invalid.
27 This implementation of <<wctomb>> returns <<0>> if
28 <[s]> is <<NULL>>; it returns <<-1>> if _MB_CAPABLE is enabled
29 and the wchar is not a valid multi-byte character, it returns <<1>>
30 if _MB_CAPABLE is not defined or the wchar is in reality a single
31 byte character, otherwise it returns the number of bytes in the
35 <<wctomb>> is required in the ANSI C standard. However, the precise
36 effects vary with the locale.
38 <<wctomb>> requires no supporting OS subroutines.
48 #ifdef _REENT_THREAD_LOCAL
49 _Thread_local _mbstate_t _tls_wctomb_state
;
57 struct _reent
*reent
= _REENT
;
59 _REENT_CHECK_MISC(reent
);
61 return __WCTOMB (reent
, s
, wchar
, &(_REENT_WCTOMB_STATE(reent
)));
62 #else /* not _MB_CAPABLE */
66 /* Verify that wchar is a valid single-byte character. */
67 if ((size_t)wchar
>= 0x100) {
74 #endif /* not _MB_CAPABLE */
77 #endif /* !_REENT_ONLY */