PowerShell使用UTF-8(powershell format)

PowerShell使用UTF-8(powershell format)

编码文章call10242025-02-01 3:36:3310A+A-

最近在使用编程IDE环境时,IDE带的终端窗口中文显示乱码,找其原因是 PowerShell 默认没有使用 UTF-8。研究了下,解决方法如下:

编写PowerShell配置文件

  • 以管理员身份打开PowerShell
  • 创建配置文件
New-Item -ItemType File -Path $PROFILE -Force
    • 编辑配置文件
notepad $PROFILE
  • 配置文件写入
[System.Console]::OutputEncoding = [System.Console]::InputEncoding = [System.Text.Encoding]::UTF8

重开一个PowerShell,OK!

如遇“因为在此系统上禁止运行脚本”

运行如下命令,重新打开即可

set-executionpolicy remotesigned
点击这里复制本文地址 以上内容由文彬编程网整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
qrcode

文彬编程网 © All Rights Reserved.  蜀ICP备2024111239号-4