I am trying to print out the string 汉字 in Visual Studio 2019 C++. Something I think I should say is probably, I'm on Windows 10 and I have been trying to figure this out using the internet for an hour to no prevail.
This is my code:
#include <iostream>
int main(void) {
std::wstring myWString = L"汉字"; // Tried a wstring, didn't output anything
std::string myString = "汉字"; // Tried using a normal string, it outputted the �'s
std::wcout << myWString << std::endl;
std::cout << myString << std::endl;
}
In the projects properties, I added /source-charset:utf-8 /execution-charset:utf-8
to the additional options in Command Line under C/C++, and I also checked Beta: Use Unicode UTF-8 for worldwide language support.
in my region settings. So why can't I print out these characters, and is this fixable, if so how?
Fixed: I went to my registry editor into HKEY_CURRENT_USER\Control Panel\Input Method
, added a new value named EnableHexNumpad and set the data to '1'. After that I restarted my PC and it worked.