Windows 10 powershell 中文乱码解决方案


Windows 10 powershell 中文乱码解决方案

Intro

我装的系统是英文版的 win 10 操作系统,最近使用命令行测试接口,发现中文显示一直异常,
使用网上的各种解决方案都没有效果,update 注册表,设置 codepage 为 utf8(65001) 都没什么卵用。

后来发现另外一台机器上是正常的(中文操作系统),chcp 查看使用的 codepage 是 936,网上查询之后 936 对应的是 简体中文,于是配置在 powershell 命令行启动的时候配置 codepage 为 936 就可以了

Solution

  1. 找到 powershell Profile,可以在powershell 环境中输入 $Profile 就可以得到 Profile 文件的路径
  2. 修改上面得到的 Profile File,在文件最后增加 chcp 936 来设置 powershell 的 codePage 为简体中文,保存后重启 powershell
  3. 新打开一个 powershell 会话,测试一下中文是否异常


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2024 CODEPRJ.COM