1#include <locale.h>
2#include <wchar.h>
3#include <stdio.h>
4#include <stdlib.h>
5
6/* MB_CUR_MAX multibyte ones (6 UTF+0080, in this case) */
7static const char string[] = "\
8\xc2\x80\xc2\x80\xc2\x80\xc2\x80\xc2\x80\xc2\x80";
9
10int
11main (void)
12{
13 if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
14 {
15 puts (s: "cannot set locale");
16 exit (1);
17 }
18
19 wchar_t s[7];
20 int n = sscanf (string, "%l[\x80\xc2]", s);
21 if (n != 1)
22 {
23 printf (format: "return values %d != 1\n", n);
24 exit (1);
25 }
26
27 return 0;
28}
29

source code of glibc/stdio-common/bug14.c