2 * Copyright © 2023 Nick Bowler
4 * Simplified mbsnwidth for test purposes.
6 * License WTFPL2: Do What The Fuck You Want To Public License, version 2.
7 * This is free software: you are free to do what the fuck you want to.
8 * There is NO WARRANTY, to the extent permitted by law.
17 int mbsnwidth(const char *buf, size_t buflen, int flags)
19 static int initialized;
24 setlocale(LC_CTYPE, "");
28 memset(&ps, 0, sizeof ps);
34 l = mbrtowc(&wc, buf, buflen, &ps);
35 if (l == (size_t)-1 || l == (size_t)-2)