Welcome to mirror list, hosted at ThFree Co, Russian Federation.

wctob.c « stdlib « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4288c54a84c904fabe7ff73ab1ad059e5d78e035 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <wchar.h>
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
#include <reent.h>

int
wctob (wint_t c)
{
  mbstate_t mbs;
  int retval = 0;
  unsigned char pwc;

  /* Put mbs in initial state. */
  memset (&mbs, '\0', sizeof (mbs));

  _REENT_CHECK_MISC(_REENT);

  retval = _wctomb_r (_REENT, &pwc, c, &mbs);

  if (c == EOF || retval != 1)
    return WEOF;
  else
    return (int)pwc;
}