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

wctob.c « mingwex « mingw « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 01a57bf3a4b474266ecccdcb5b93f1644ae4908c (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_codepage(), 
			      0 /* Is this correct flag? */,
			      &w, 1, &c, 1, NULL, &invalid_char)
         || invalid_char)
      return EOF;
    return (int) c;
}