How to write "Ni Hao" ("Hello") in Chinese to standard output using UTF-8 in C

1 Answer

0 votes
#include <stdio.h>
#include <wchar.h> // wprintf
#include <locale.h> // setlocale

int main() {
    // Set the locale to UTF-8
    setlocale(LC_ALL, "en_US.UTF-8");

    // Print wide string
    wprintf(L"你好\n");

    return 0;
}



/*
run:

你好

*/

 



answered Aug 14, 2025 by avibootz
...