master
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#ifndef WIN32_LEAN_AND_MEAN
7#define WIN32_LEAN_AND_MEAN
8#endif
9#include "mb_wc_common.h"
10#include <wchar.h>
11#include <stdio.h>
12#include <stdlib.h>
13#include <errno.h>
14#include <windows.h>
15
16/* Return just the first byte after translating to multibyte. */
17int wctob (wint_t wc )
18{
19 wchar_t w = wc;
20 char c;
21 int invalid_char = 0;
22 if (!WideCharToMultiByte (___lc_codepage_func(),
23 0 /* Is this correct flag? */,
24 &w, 1, &c, 1, NULL, &invalid_char)
25 || invalid_char)
26 return EOF;
27
28 return (unsigned char) c;
29}