forked from KolibriOS/kolibrios
newlib: wide char support
git-svn-id: svn://kolibrios.org@6607 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
33
contrib/sdk/sources/newlib/libc/stdlib/btowc.c
Normal file
33
contrib/sdk/sources/newlib/libc/stdlib/btowc.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <wchar.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <reent.h>
|
||||
#include <string.h>
|
||||
#include "local.h"
|
||||
|
||||
wint_t
|
||||
btowc (int c)
|
||||
{
|
||||
mbstate_t mbs;
|
||||
int retval = 0;
|
||||
wchar_t pwc;
|
||||
unsigned char b;
|
||||
|
||||
if (c == EOF)
|
||||
return WEOF;
|
||||
|
||||
b = (unsigned char)c;
|
||||
|
||||
/* Put mbs in initial state. */
|
||||
memset (&mbs, '\0', sizeof (mbs));
|
||||
|
||||
_REENT_CHECK_MISC(_REENT);
|
||||
|
||||
retval = __mbtowc (_REENT, &pwc, (const char *) &b, 1,
|
||||
__locale_charset (), &mbs);
|
||||
|
||||
if (retval != 0 && retval != 1)
|
||||
return WEOF;
|
||||
|
||||
return (wint_t)pwc;
|
||||
}
|
Reference in New Issue
Block a user