1#include <locale.h>
2#include <stdint.h>
3#include <stdlib.h>
4#include <stdio.h>
5
6int
7main (void)
8{
9 wchar_t wc;
10
11 if (setlocale (LC_CTYPE, "de_DE.UTF-8") == NULL)
12 {
13 puts (s: "setlocale failed");
14 return 1;
15 }
16
17 if (mbtowc (&wc, "\xc3\xa1", MB_CUR_MAX) != 2 || wc != 0xE1)
18 {
19 puts (s: "1st mbtowc failed");
20 return 1;
21 }
22
23 if (mbtowc (pwc: &wc, s: "\xc3\xa1", SIZE_MAX) != 2 || wc != 0xE1)
24 {
25 puts (s: "2nd mbtowc failed");
26 return 1;
27 }
28
29 return 0;
30}
31

source code of glibc/stdlib/testmb2.c