I want to print UTF-8 characters with C programming language. I've tried this but failed:
#include<stdio.h>
#include<stdlib.h>
#include<locale.h>
#include<wchar.h>
int main(){
if(setlocale(LC_ALL, "zh-CN.UTF-8")!=NULL){
printf("Error.\n");
}
wchar_t *hello=L"你好";
wprintf(L"%ls\n", hello);
}
And the result:
$ gcc main.c
$ a
??
You can follow the link to see the picture: https://i.stack.imgur.com/PZKaa.png.
Can anyone help me?