[Windows 10]Codex 在 VS Code 中中文乱码时

遇到 Codex 在 VS Code 中中文乱码时,可直接操作:


1. 检查当前 PowerShell 编码

 
chcp
[Console]::OutputEncoding
$OutputEncoding
  • chcp = 936 → GBK(会乱码)

  • chcp = 65001 → UTF-8(正常)


2. 临时切换为 UTF-8

 
chcp 65001
$OutputEncoding = [Console]::OutputEncoding = [Text.UTF8Encoding]::new($true)

仅当前窗口有效。


3. 永久生效(推荐)

  1. 允许用户脚本执行:

     
    Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
  2. 编辑配置文件:

     
    notepad $PROFILE
  3. 添加以下内容:

     
    # 强制 UTF-8 编码
    chcp 65001 > $null
    $OutputEncoding = [Console]::OutputEncoding = [Text.UTF8Encoding]::new($true)
  4. 保存并关闭,重启 PowerShell。


4. 验证

 
chcp # 应显示 65001
[Console]::OutputEncoding # 应为 System.Text.UTF8Encoding

这样设置后,Codex Agent 调用 PowerShell 输出中文就不会再出现问号或乱码。

给TA打赏
共{{data.count}}人
人已打赏
C#DotNet Core

Blog.Core .Net Core 权限管理应用

2022-4-13 20:43:36

C#

C# 绑定数据源后无法取出数据

2020-4-12 18:59:13

各类网站开发

站长微信 710 342 444 或者扫一扫右侧二维码。
    0 条回复 A文章作者 M管理员
      暂无讨论,说说你的看法吧
    个人中心
    购物车
    优惠劵
    今日签到
    有新私信 私信列表
    搜索