flnxi-Wu/docs/archive/修复PowerShell编码.ps1
WuYongJie f646b71813
Some checks failed
CI Check / check (push) Has been cancelled
chore: 初始化本地仓库并同步最近改动
2025-11-18 17:50:16 +08:00

33 lines
1.4 KiB
PowerShell

# PowerShell 编码修复脚本
# 用于解决 PowerShell 和 Cursor 中的中文乱码问题
Write-Host "正在修复 PowerShell 编码设置..." -ForegroundColor Yellow
# 1. 设置控制台代码页为 UTF-8
chcp 65001 | Out-Null
# 2. 设置 PowerShell 输出编码为 UTF-8
$OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
# 3. 设置 PowerShell 输入编码为 UTF-8
[Console]::InputEncoding = [System.Text.Encoding]::UTF8
# 4. 测试中文显示
Write-Host "`n✅ 编码设置已更新!" -ForegroundColor Green
Write-Host "测试中文显示:你好世界 🌏" -ForegroundColor Cyan
Write-Host "测试特殊字符:①②③ ⭐⭐" -ForegroundColor Yellow
# 5. 显示当前编码信息
Write-Host "`n当前编码信息:" -ForegroundColor Yellow
Write-Host " 控制台代码页: $([Console]::OutputEncoding.CodePage)" -ForegroundColor White
Write-Host " 输出编码: $($OutputEncoding.EncodingName)" -ForegroundColor White
Write-Host " 输入编码: $([Console]::InputEncoding.EncodingName)" -ForegroundColor White
Write-Host "`n💡 提示:" -ForegroundColor Cyan
Write-Host " 1. 如果问题仍然存在,请重启 PowerShell 或 Cursor" -ForegroundColor White
Write-Host " 2. 可以在 PowerShell 配置文件中添加这些设置(永久生效)" -ForegroundColor White
Write-Host " 3. Cursor 设置中检查终端编码设置" -ForegroundColor White