#include <stdlib.h>
#include <locale.h>
#include <stdio.h>
int main()
{
setlocale(LC_ALL
, "en_US.utf8"); // or any other utf8 locale wchar_t c = L'\u00a1'; // or = L'\xa1';
char mb[MB_CUR_MAX + 1];
int len = wctomb(mb, c);
mb[len] = '\0';
printf("UTF-8 char: %s\n", mb
); }
I2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8bG9jYWxlLmg+CiNpbmNsdWRlIDxzdGRpby5oPgppbnQgbWFpbigpCnsKICAgIHNldGxvY2FsZShMQ19BTEwsICJlbl9VUy51dGY4Iik7IC8vIG9yIGFueSBvdGhlciB1dGY4IGxvY2FsZQogICAgd2NoYXJfdCBjID0gTCdcdTAwYTEnOyAvLyBvciA9IEwnXHhhMSc7CiAgICBjaGFyIG1iW01CX0NVUl9NQVggKyAxXTsKICAgIGludCBsZW4gPSB3Y3RvbWIobWIsIGMpOwogICAgbWJbbGVuXSA9ICdcMCc7CiAgICBwcmludGYoIlVURi04IGNoYXI6ICVzXG4iLCBtYik7Cn0K