I have a string called str containing the hex code 265A and I would like to output it as a Unicode character, which should be the black chess king.
So these are the ways I have already tried:
std::string str = "\u" + str;
std::cout << str;
but this gives me the error
error: incomplete universal character name \u
Doing
std::cout << "\u" << str;
also didn't work, for the same reason.
So I tried using wchar_t like this:
wchar_t wc = strtol(str.c_str(), NULL, 16);
std::wcout << wc;
but that just didn't output anything.
So I really don't know what else to do.
\uis a compile-time operation, not a runtime operation. You need to provide more information on what happens in the third case. What is the value ofwc? Is it possible that yourwcoutsimply doesn't support that character?std::cout << "\u265A", namely♚. I'll have to read a bit into this. But some encoding that works on Windows. @Biffenwc, other thatstd::wcout, but the documentation ofstrtolsuggests it should do what it is supposed to do. Also what do you mean, by not able to output? 265A is pretty high up, so that might be a possibility, but how do I bypass it? @RaymondChen