- Home
- Skills
- Testing & Debugging
- Windows Encoding Hardening
Windows Encoding Hardening
by Smith John
Fix Windows mojibake in four layers: script BOM, console output, piped stdio, shell interop.
$5
Windows Encoding Hardening
Example session with this skill installed
我的 .ps1 里中文全是乱码,报「无效的值」,Python 也报 'gbk' codec can't encode character
- Read your context and instructions
- Compiled the windows encoding hardening
先判层:.ps1 无 BOM + 中文 = 第 1 层 → 另存 UTF-8 带 BOM,路径改从 param() 传入;emoji 崩 GBK = 第 2 层 → 落文件或换 [FAIL] 标记。附录脚本一条命令取证。
Connects securely to your tools. The creator never sees your data.
About this skill
Windows 上中文变乱码,99% 不是「文件坏了」,而是某一层的默认编码不是 UTF-8。
这个技能把问题分成四层,每层都给了症状、一步验证和修法:
- 脚本文件 — .ps1 无 BOM 会被按 GBK 解码,中文字面量变乱码、中文路径报「无效的值」
- 控制台输出 — 屏幕乱码但文件正常,先证明是显示坏不是文件坏
- 子进程管道 stdio — 重定向绕过 chcp 65001,中文变问号或抛编码异常
- shell 互操作 — Git-Bash/MSYS 改写传给 exe 的路径
另外收了三个伪装成编码问题的坑:文本模式写坏二进制、Get-ChildItem -Recurse 超长路径静默少算、中文路径做进程签名匹配不到导致误判进程没在跑。
文末附录带一个纯 ASCII 的取证脚本,一条命令打出 PowerShell 版本、ANSI/OEM 代码页、控制台编码、是否在 MSYS、每个文件的 BOM/UTF-8 合法性/非 ASCII 字节数、Python stdio 编码——第 1 层和第 3 层的问题一次定位。
适合:在 Windows 上写脚本、跑 Python、调 CLI 的人(或让 AI 代跑这些活)。 不适合:Linux/容器里的 locale 问题——那是另一套(LANG/locale),本技能不管。
只覆盖 Windows 上的编码问题:Linux / 容器里的 LANG、locale 不在范围内。PowerShell 7+ 默认 UTF-8,第 1 层(BOM)的规则对它用不上。技能不代跑程序,只给判层方法与取证脚本。
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 16 days ago
Windows only
- Software
- PowerShell 5.1 or later
Permissions
What's inside
Frequently Asked Questions
New in Testing & Debugging
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Testing & Debugging.