The first answer did not work for me, the second - more than I want. So I combined the two answers:
setlocale(LC_CTYPE, "xx_XX.UTF-8"); // or "xx_XX.utf8", it means the same
where xx_XX is some language tag. I tried to write strings in many languages ββwith different alphabets (in LINUX, including Chinese, language from left to right and rigth-to-left); so i tried:
setlocale(LC_CTYPE, "it_IT.UTF-8");
and he worked with any tested language. I canβt understand why the simple βUTF-8β without specifying the language xx_XX does not work, since I use UTF8 as a language-independent and should not specify it. (If someone knows the reason for this, it would be an interesting improvement in the answer). Perhaps this also depends on the Operatin system.
Finally, on Linux, you can get a list of encodings by typing on the shell:
fresko
source share