#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/locale/wctomb.c,v 1.8 2004/07/29 06:18:40 tjr Exp $");
+#include "xlocale_private.h"
+
#include <stdlib.h>
#include <wchar.h>
#include "mblocal.h"
int
-wctomb(char *s, wchar_t wchar)
+wctomb_l(char *s, wchar_t wchar, locale_t loc)
{
static const mbstate_t initial;
- static mbstate_t mbs;
size_t rval;
+ NORMALIZE_LOCALE(loc);
if (s == NULL) {
/* No support for state dependent encodings. */
- mbs = initial;
+ loc->__mbs_wctomb = initial;
return (0);
}
- if ((rval = __wcrtomb(s, wchar, &mbs)) == (size_t)-1)
+ if ((rval = loc->__lc_ctype->__wcrtomb(s, wchar, &loc->__mbs_wctomb, loc)) == (size_t)-1)
return (-1);
return ((int)rval);
}
+
+int
+wctomb(char *s, wchar_t wchar)
+{
+ return wctomb_l(s, wchar, __current_locale());
+}