summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/btowc.c
blob: 36f392bf8046aa7c81df9e173e7daff8502e2e97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>

#define CODEUNIT(c) (0xdfff & (signed char)(c))

wint_t btowc(int c)
{
	if ((unsigned char)c < 128U) {
		return c;
	}

	if (MB_CUR_MAX == 1 && c != EOF) {
		return CODEUNIT(c);
	}

	return WEOF;
}