I’m mainly working with cpp, recently. Sometimes, I have some Chinese characters in the input/output stream, the the encoding issue became annoy.
After some search, I found the way out.
the method to make your utf-8 coded program work in GBK scenario.
add the following line to your code.
#include <clocale>
#include<stdio.h>
char* dummyGlobalVarAA =std::setlocale(LC_ALL, "en_US.UTF-8");
int main(int argc, char **argv)
{
printf("abc中文\n");
return 0;
}
ref
std::setlocale - cppreference.com
https://en.cppreference.com/w/cpp/locale/setlocale