C++ cmd.exe和powershell.exe中的控制台输出通过C++;

C++ cmd.exe和powershell.exe中的控制台输出通过C++;,c++,powershell,console,cmd,C++,Powershell,Console,Cmd,我知道一种在Cmd.exe上正确显示本地化字符的简单方法。但是我如何才能对Powershell.exe执行相同的操作呢 #include<iostream> #include<windows.h> using namespace std; int main() { SetConsoleCP(GetACP()); SetConsoleOutputCP(GetACP()); // valid output in cmd.exe, // b

我知道一种在
Cmd.exe
上正确显示本地化字符的简单方法。但是我如何才能对Powershell.exe执行相同的操作呢

#include<iostream>
#include<windows.h>

using namespace std;
int main()
{
    SetConsoleCP(GetACP());
    SetConsoleOutputCP(GetACP());

    // valid output in cmd.exe, 
    // but invalid output in powershell.exe
    cout << "Привет мир (1)!" << endl; 

    // invalid output in both variants: cmd.exe, 
    // and powershell.exe
    wcout << L"Привет мир (2)!" << endl; 

    return 0;
}
#包括
#包括
使用名称空间std;
int main()
{
SetConsoleCP(GetACP());
SetConsoleOutputCP(GetACP());
//cmd.exe中的有效输出,
//但powershell.exe中的输出无效

cout输出是什么?您的字体支持这些字形吗

以下链接可能有用(关于cmd.exe):

您还可以尝试将powershell的输出重定向到一个文件并进行检查。如果该文件正确,则说明控制台字体不支持您的字符

微软还有一个博客,展示了如何定制字体(关于ps)


我认为这是一个快捷方式,可以在Windows中启用正确的
wcout
处理。请尝试将其作为
主文件的第一行添加到

_setmode(_fileno(stdout), _O_U16TEXT);
之后,
wcout