fix: 移除 BOM 并增强 UTF-8 编码修复
- 移除 UTF-8 BOM (BOM 会破坏 iwr|iex 管道导致 param() 报错) - 去掉 $Host.Name 守卫,无条件设置 Console 编码 (try/catch 兜底) - chcp 65001 先于 Console.OutputEncoding 设置,确保代码页一致
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# Claude Code Configuration Script for XCodeCLI (Windows)
|
# Claude Code Configuration Script for XCodeCLI (Windows)
|
||||||
# This script configures Claude Code to use your XCodeCLI instance
|
# This script configures Claude Code to use your XCodeCLI instance
|
||||||
# Run with: powershell -ExecutionPolicy Bypass -File setup-claude-code.ps1 -ApiKey YOUR_KEY
|
# Run with: powershell -ExecutionPolicy Bypass -File setup-claude-code.ps1 -ApiKey YOUR_KEY
|
||||||
# Or via one-liner: & { $key='YOUR_KEY'; iwr -useb https://api.xcodecli.com/setup-claude-code.ps1 | iex }
|
# Or via one-liner: & { $key='YOUR_KEY'; iwr -useb https://api.xcodecli.com/setup-claude-code.ps1 | iex }
|
||||||
@@ -17,14 +17,12 @@ if (-not $ApiKey -and (Test-Path Variable:key)) { $ApiKey = $key }
|
|||||||
# 确保中文字符在各种 PowerShell 环境中正确显示
|
# 确保中文字符在各种 PowerShell 环境中正确显示
|
||||||
# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex
|
# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex
|
||||||
try {
|
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') {
|
if ($env:OS -eq 'Windows_NT') {
|
||||||
& cmd /c "chcp 65001 >nul" 2>&1 | Out-Null
|
& cmd /c "chcp 65001 >nul" 2>&1 | Out-Null
|
||||||
}
|
}
|
||||||
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
[Console]::InputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
$OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Gemini CLI Configuration Script for XCodeCLI (Windows)
|
# Gemini CLI Configuration Script for XCodeCLI (Windows)
|
||||||
# This script configures Gemini CLI to use your XCodeCLI instance
|
# This script configures Gemini CLI to use your XCodeCLI instance
|
||||||
# Automatically tests multiple API endpoints and selects the working one
|
# Automatically tests multiple API endpoints and selects the working one
|
||||||
# Run with: powershell -ExecutionPolicy Bypass -File setup-gemini.ps1 -ApiKey YOUR_KEY
|
# Run with: powershell -ExecutionPolicy Bypass -File setup-gemini.ps1 -ApiKey YOUR_KEY
|
||||||
@@ -17,14 +17,12 @@ if (-not $ApiKey -and (Test-Path Variable:key)) { $ApiKey = $key }
|
|||||||
# 确保中文字符在各种 PowerShell 环境中正确显示
|
# 确保中文字符在各种 PowerShell 环境中正确显示
|
||||||
# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex
|
# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex
|
||||||
try {
|
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') {
|
if ($env:OS -eq 'Windows_NT') {
|
||||||
& cmd /c "chcp 65001 >nul" 2>&1 | Out-Null
|
& cmd /c "chcp 65001 >nul" 2>&1 | Out-Null
|
||||||
}
|
}
|
||||||
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
[Console]::InputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
$OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
|
|||||||
@@ -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
|
# This script configures Codex to use your XCodeCLI instance
|
||||||
# Automatically tests multiple API endpoints and selects the working one
|
# Automatically tests multiple API endpoints and selects the working one
|
||||||
# Run with: powershell -ExecutionPolicy Bypass -File setup-codex.ps1 -ApiKey YOUR_KEY
|
# Run with: powershell -ExecutionPolicy Bypass -File setup-codex.ps1 -ApiKey YOUR_KEY
|
||||||
@@ -17,14 +17,12 @@ if (-not $ApiKey -and (Test-Path Variable:key)) { $ApiKey = $key }
|
|||||||
# 确保中文字符在各种 PowerShell 环境中正确显示
|
# 确保中文字符在各种 PowerShell 环境中正确显示
|
||||||
# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex
|
# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex
|
||||||
try {
|
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') {
|
if ($env:OS -eq 'Windows_NT') {
|
||||||
& cmd /c "chcp 65001 >nul" 2>&1 | Out-Null
|
& cmd /c "chcp 65001 >nul" 2>&1 | Out-Null
|
||||||
}
|
}
|
||||||
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
[Console]::InputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
$OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
|
|||||||
BIN
ef01e1d7cb66896f9c042ca96ba35f2e.png
Normal file
BIN
ef01e1d7cb66896f9c042ca96ba35f2e.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
@@ -1,4 +1,4 @@
|
|||||||
# Claude Code Configuration Script for XCodeCLI (Windows)
|
# Claude Code Configuration Script for XCodeCLI (Windows)
|
||||||
# This script configures Claude Code to use your XCodeCLI instance
|
# This script configures Claude Code to use your XCodeCLI instance
|
||||||
# Run with: powershell -ExecutionPolicy Bypass -File setup-claude-code.ps1 -ApiKey YOUR_KEY
|
# Run with: powershell -ExecutionPolicy Bypass -File setup-claude-code.ps1 -ApiKey YOUR_KEY
|
||||||
# Or via one-liner: & { $key='YOUR_KEY'; iwr -useb https://api.xcodecli.com/setup-claude-code.ps1 | iex }
|
# Or via one-liner: & { $key='YOUR_KEY'; iwr -useb https://api.xcodecli.com/setup-claude-code.ps1 | iex }
|
||||||
@@ -17,14 +17,12 @@ if (-not $ApiKey -and (Test-Path Variable:key)) { $ApiKey = $key }
|
|||||||
# 确保中文字符在各种 PowerShell 环境中正确显示
|
# 确保中文字符在各种 PowerShell 环境中正确显示
|
||||||
# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex
|
# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex
|
||||||
try {
|
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') {
|
if ($env:OS -eq 'Windows_NT') {
|
||||||
& cmd /c "chcp 65001 >nul" 2>&1 | Out-Null
|
& cmd /c "chcp 65001 >nul" 2>&1 | Out-Null
|
||||||
}
|
}
|
||||||
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
[Console]::InputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
$OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
|
|||||||
15
setup.ps1
15
setup.ps1
@@ -1,4 +1,4 @@
|
|||||||
# XCodeCLI Setup Launcher (Windows)
|
# XCodeCLI Setup Launcher (Windows)
|
||||||
# 一站式安装和配置 Claude Code, Gemini CLI, Codex
|
# 一站式安装和配置 Claude Code, Gemini CLI, Codex
|
||||||
|
|
||||||
param(
|
param(
|
||||||
@@ -13,18 +13,17 @@ if (-not $ApiKey -and (Test-Path Variable:key)) { $ApiKey = $key }
|
|||||||
# 确保中文字符在各种 PowerShell 环境中正确显示
|
# 确保中文字符在各种 PowerShell 环境中正确显示
|
||||||
# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex
|
# 兼容: Windows PowerShell 5.x, PowerShell 7.x, Windows Terminal, conhost, ISE, iwr|iex
|
||||||
try {
|
try {
|
||||||
if ($Host.Name -eq 'ConsoleHost') {
|
# 1. 先设置控制台代码页为 UTF-8
|
||||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
||||||
[Console]::InputEncoding = [System.Text.Encoding]::UTF8
|
|
||||||
}
|
|
||||||
$OutputEncoding = [System.Text.Encoding]::UTF8
|
|
||||||
# Windows 下同步控制台代码页为 UTF-8
|
|
||||||
if ($env:OS -eq 'Windows_NT') {
|
if ($env:OS -eq 'Windows_NT') {
|
||||||
& cmd /c "chcp 65001 >nul" 2>&1 | Out-Null
|
& cmd /c "chcp 65001 >nul" 2>&1 | Out-Null
|
||||||
}
|
}
|
||||||
|
# 2. 设置 .NET 控制台编码 (Write-Host 依赖此设置)
|
||||||
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
[Console]::InputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
# 3. 设置 PowerShell 管道/cmdlet 输出编码
|
||||||
|
$OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
} catch {
|
} catch {
|
||||||
# 静默处理 - ISE 等环境可能不支持 Console 类操作
|
# 静默处理 - ISE 等环境可能不支持 Console 类操作
|
||||||
}
|
|
||||||
|
|
||||||
# ========== 颜色输出函数 ==========
|
# ========== 颜色输出函数 ==========
|
||||||
function Write-Info { param([string]$Message); Write-Host "[INFO]" -ForegroundColor Blue -NoNewline; Write-Host " $Message" }
|
function Write-Info { param([string]$Message); Write-Host "[INFO]" -ForegroundColor Blue -NoNewline; Write-Host " $Message" }
|
||||||
|
|||||||
Reference in New Issue
Block a user