[英]How do I use alt code symbols in c++ visual studio
I'm using visual studio for C++ and when using alt
symbols it returns a ?
我正在使用 Visual Studio for C++,当使用
alt
符号时,它返回一个?
. . Why?
为什么?
You can use您可以使用
setlocale(LC_CTYPE, Encoding what you need );
setlocale(LC_CTYPE,编码你需要的);
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:您可以借助
fcntl.h
库:
#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 .注意:您可以在Wikipedia 中找到 Unicode 字符集的完整列表。
It'll print the symbols correctly:它将正确打印符号:
Hello, ♣!
As an image example:作为图像示例:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.