fix: 修复 PowerShell 脚本中文乱码问题
- 在所有 .ps1 脚本中添加 UTF-8 编码兼容块 (Console OutputEncoding/InputEncoding + chcp 65001) - 兼容 Windows PowerShell 5.x, PS 7.x, Windows Terminal, conhost, ISE - 添加 UTF-8 BOM 确保本地执行时编码正确识别 - try/catch 静默处理不支持 Console 类的环境
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Codex Configuration Script for XCodeCLI (Windows)
|
||||
# Codex Configuration Script for XCodeCLI (Windows)
|
||||
# This script configures Codex to use your XCodeCLI instance
|
||||
# Automatically tests multiple API endpoints and selects the working one
|
||||
# Run with: powershell -ExecutionPolicy Bypass -File setup-codex.ps1 -ApiKey YOUR_KEY
|
||||
@@ -13,6 +13,20 @@ param(
|
||||
# Check for pre-set variables from one-liner command
|
||||
if (-not $ApiKey -and (Test-Path Variable:key)) { $ApiKey = $key }
|
||||
|
||||
# ========== UTF-8 编码兼容 ==========
|
||||
# 确保中文字符在各种 PowerShell 环境中正确显示
|
||||
# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex
|
||||
try {
|
||||
if ($Host.Name -eq 'ConsoleHost') {
|
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
[Console]::InputEncoding = [System.Text.Encoding]::UTF8
|
||||
}
|
||||
$OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
if ($env:OS -eq 'Windows_NT') {
|
||||
& cmd /c "chcp 65001 >nul" 2>&1 | Out-Null
|
||||
}
|
||||
} catch { }
|
||||
|
||||
# Configuration
|
||||
$DefaultBaseUrl = "https://api2.xcodecli.com"
|
||||
$CodexConfigDir = "$env:USERPROFILE\.codex"
|
||||
|
||||
Reference in New Issue
Block a user