I'm using visual studio for C++ and when using alt
symbols it returns a ?
. Why?
You can use
setlocale(LC_CTYPE, Encoding what you need );
Maybe not the best, but simple option to set console encoding output on what we want.
You've not set any supported encoding for your program and it's commonly not used in console, that's why you're getting the error. Although, this's yet possible.
You may take the help of fcntl.h
library:
#include <iostream>
#include <fcntl.h>
int main(int) {
_setmode(_fileno(stdout), _O_U16TEXT);
std::wcout << L"Hello, \u2663!\n";
return 0;
}
Note: You may find out the complete list of Unicode character set in Wikipedia .
It'll print the symbols correctly:
Hello, ♣!
As an image example:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.