惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
J
Java Code Geeks
C
Check Point Blog
Last Week in AI
Last Week in AI
Microsoft Azure Blog
Microsoft Azure Blog
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
L
LangChain Blog
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 司徒正美
IT之家
IT之家
Martin Fowler
Martin Fowler
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
U
Unit 42
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ

轶哥博客

blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog
blog
2022-04-06 · via 轶哥博客

修改$Profile文件(notepad.exe $Profile),添加

$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding

说明:上述操作修改了输出编码为UTF-8,兼容了大部分的程序输出的中文。

需要注意的是,PowerShell7仅修改chcp 65001无法实现对程序输出中文的支持。另外,修改控制面板-区域-管理-更改系统区域设置里面的设置,启用Beta版:使用Unicode UTF-8提供全球语言支持,也可以达到同样的效果,但是很多中文应用程序,包括操作系统自带的应用程序,将会出现中文显示异常。不推荐此方案!

区域设置.png

以上方法在win10、win11系统安装的Powershell 7.2.2版本测试通过。

如果上述操作后仍然无法正常显示中文,应该是没有正确配置中文字体。推荐安装windows terminal,设置等宽且支持中文的字体。推荐支持Retina的等宽字体FiraCode Nerd Font Mono Retina

terminal.png

如果在VSCode中无法正常显示,参考以下配置:

{
  "terminal.external.windowsExec": "C:\\Program Files\\PowerShell\\7\\pwsh.exe --nologo",
  "editor.fontFamily": "'FiraCode Nerd Font Mono Retina', 'Microsoft YaHei Mono', Consolas, 'Courier New', monospace",
  "terminal.integrated.minimumContrastRatio": 1,
  "terminal.integrated.defaultProfile.windows": "PowerShell",
  "terminal.integrated.profiles.windows": {
    "PowerShell": {
      "path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
      "args": [
        "--nologo"
      ],
      "source": "PowerShell",
      "icon": "terminal-powershell"
    }
  }
}

vscode.png

其中minimumContrastRatio是终端无法正常显示文字背景色的配置方法。