gpt4 book ai didi

c++ - cmd.exe 中的控制台输出,以及通过 C++ 的 powershell.exe

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:23:55 25 4
gpt4 key购买 nike

我知道一种在 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;
}

最佳答案

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

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

http://www.watchingthenet.com/how-to-add-and-change-fonts-in-windows-command-prompt.html

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

还有一篇ms的博客,展示了如何自定义字体(关于ps)

http://blogs.msdn.com/b/powershell/archive/2006/10/16/windows-powershell-font-customization.aspx

关于c++ - cmd.exe 中的控制台输出,以及通过 C++ 的 powershell.exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13235385/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com