blob: 2b40fc1d0a95d76d39d80c9c17f3e0ea0551f8e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include "mb_wc_common.h"
#include <wchar.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
/* Return just the first byte after translating to multibyte. */
int wctob (wint_t wc )
{
wchar_t w = wc;
char c;
int invalid_char = 0;
if (!WideCharToMultiByte (get_cp_from_locale(),
0 /* Is this correct flag? */,
&w, 1, &c, 1, NULL, &invalid_char)
|| invalid_char)
return EOF;
return (int) c;
}
|