summaryrefslogtreecommitdiffstats
path: root/winsup/mingw/mingwex/btowc.c
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/mingw/mingwex/btowc.c')
-rwxr-xr-xwinsup/mingw/mingwex/btowc.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/winsup/mingw/mingwex/btowc.c b/winsup/mingw/mingwex/btowc.c
new file mode 100755
index 000000000..b369190d7
--- /dev/null
+++ b/winsup/mingw/mingwex/btowc.c
@@ -0,0 +1,19 @@
+#include "mb_wc_common.h"
+#include <wchar.h>
+#include <stdio.h>
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+wint_t btowc (int c)
+{
+ if (c == EOF)
+ return (WEOF);
+ else
+ {
+ unsigned char ch = c;
+ wchar_t wc = WEOF;
+ MultiByteToWideChar (get_cp_from_locale(), MB_ERR_INVALID_CHARS,
+ (char*)&ch, 1, &wc, 1);
+ return wc;
+ }
+}