.Dt WCTOMB 3
.Os
.Sh NAME
-.Nm wctomb
+.Nm wctomb ,
+.Nm wctomb_l
.Nd convert a wide-character code to a character
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In stdlib.h
.Ft int
-.Fn wctomb "char *mbchar" "wchar_t wchar"
+.Fo wctomb
+.Fa "char *s"
+.Fa "wchar_t wchar"
+.Fc
+.In stdlib.h
+.In xlocale.h
+.Ft int
+.Fo wctomb_l
+.Fa "char *s"
+.Fa "wchar_t wchar"
+.Fa "locale_t loc"
+.Fc
.Sh DESCRIPTION
The
.Fn wctomb
-function converts a wide character
-.Fa wchar
-into a multibyte character and stores
-the result in
-.Fa mbchar .
+function converts a wide character,
+.Fa wchar ,
+into a multibyte character and stores the result in
+.Fa s .
The object pointed to by
-.Fa mbchar
-must be large enough to accommodate the multibyte character, which
-may be up to
+.Fa s
+must be large enough to accommodate the multibyte character,
+which may be up to
.Dv MB_LEN_MAX
bytes.
.Pp
A call with a null
-.Fa mbchar
+.Fa s
pointer returns nonzero if the current locale requires shift states,
zero otherwise;
if shift states are required, the shift state is reset to the initial state.
+.Pp
+Although the
+.Fn wctomb
+function uses the current locale, the
+.Fn wctomb_l
+function may be passed a locale directly. See
+.Xr xlocale 3
+for more information.
.Sh RETURN VALUES
If
-.Fa mbchar
+.Fa s
is
.Dv NULL ,
the
function returns nonzero if shift states are supported,
zero otherwise.
If
-.Fa mbchar
+.Fa s
is valid,
.Fn wctomb
returns
the number of bytes processed in
-.Fa mbchar ,
+.Fa s ,
or \-1 if no multibyte character
could be recognized or converted.
In this case,
.Xr mbtowc 3 ,
.Xr wcrtomb 3 ,
.Xr wcstombs 3 ,
-.Xr wctob 3
+.Xr wctob 3 ,
+.Xr xlocale 3
.Sh STANDARDS
The
.Fn wctomb