Codex Cli Windows下 乱码问题处理

jonathan
2026-03-12 / 0 评论

Codex Cli Windows下 乱码问题处理

步骤

1、新建脚本 Setup UTF-8 PowerShell Environment

# Setup UTF-8 PowerShell Environment

chcp 65001 | Out-Null

[Console]::InputEncoding  = [System.Text.UTF8Encoding]::new()
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new()

$OutputEncoding = [System.Text.UTF8Encoding]::new()

$PSDefaultParameterValues['Out-File:Encoding']    = 'utf8'
$PSDefaultParameterValues['Set-Content:Encoding'] = 'utf8'
$PSDefaultParameterValues['Add-Content:Encoding'] = 'utf8'

Write-Host "PowerShell UTF-8 environment configured successfully."

命名为Setup-UTF8PowerShell.ps1保存到目录

2、打开目录和打开powershell窗口 执行改脚本

./Setup-UTF8PowerShell.ps1

执行codex 测试下 如果报如下错误

在powershell会报codex :

 无法加载文件 C:\Program Files\nodejs\codex.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 ab out_Execution_Policies。 所在位置 行:1 字符: 1 + codex + ~~~~~ + CategoryInfo : SecurityError: (:) [],PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess

在powershell窗口执行

Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

评论

博主关闭了当前页面的评论