newlib: wide char support
git-svn-id: svn://kolibrios.org@6607 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
26
contrib/sdk/sources/newlib/libc/stdlib/wctob.c
Normal file
26
contrib/sdk/sources/newlib/libc/stdlib/wctob.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <reent.h>
|
||||
#include <wchar.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include "local.h"
|
||||
|
||||
int
|
||||
wctob (wint_t wc)
|
||||
{
|
||||
struct _reent *reent;
|
||||
mbstate_t mbs;
|
||||
unsigned char pmb[MB_LEN_MAX];
|
||||
|
||||
if (wc == WEOF)
|
||||
return EOF;
|
||||
|
||||
/* Put mbs in initial state. */
|
||||
memset (&mbs, '\0', sizeof (mbs));
|
||||
|
||||
reent = _REENT;
|
||||
_REENT_CHECK_MISC(reent);
|
||||
|
||||
return __wctomb (reent, (char *) pmb, wc, __locale_charset (), &mbs) == 1
|
||||
? (int) pmb[0] : EOF;
|
||||
}
|
Reference in New Issue
Block a user