显示“?”而不是 C++ Windows 中的 unicode 字符

问题描述

我使用 Visual Studio 2019 创建了 C++ 项目,该项目可打印俄语和亚美尼亚语字符。但是在命令行打印 ?

Source.cpp

#include <iostream>
using namespace std;

int main() {
    setlocale(LC_ALL,"ru");
    cout << "\u053e абв";
    return 0;
}

输出

? ???

也在编辑器中

当我使用 UTF-8 时,它会输出这个

╨░╨▒╨▓

当我添加显示 代码页 20861 时? 6

解决方法

我建议您可以尝试使用 the Code Page Identifiers

如下代码:

setlocale(LC_ALL,"20866");

enter image description here