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

#define IS_CODEUNIT(c) ((unsigned)(c) - 0xdf80 < 0x80)

int wctob(wint_t c)
{
	if (c < 128U)
		return (int)c;

	if (MB_CUR_MAX == 1 && IS_CODEUNIT(c))
		return (unsigned char)c;

	return EOF;
}