OSDN Git Service

Adjust repository version following WSL-5.2.2 release.
[mingw/mingw-org-wsl.git] / mingwrt / mingwex / wctob.c
1 #include "mb_wc_common.h"
2 #include <wchar.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <errno.h>
6 #define WIN32_LEAN_AND_MEAN
7 #include <windows.h>
8
9 /* Return just the first byte after translating to multibyte.  */
10 int wctob (wint_t wc )
11 {
12     wchar_t w = wc;
13     char c;
14     int invalid_char = 0;
15     if (!WideCharToMultiByte (get_codepage(),
16                               0 /* Is this correct flag? */,
17                               &w, 1, &c, 1, NULL, &invalid_char)
18          || invalid_char)
19       return EOF;
20     return (int) c;
21 }