Encoding Bug 2026-03-08 ~ 03-12

๐Ÿ”ค PowerShell Chinese Encoding Trap โ€” The Root Cause of Garbled Files

๐Ÿ”ด Problem: Used PowerShell Set-Content to write files with Chinese characters โ€” opened them to find complete gibberish. Affected IDENTITY.md, Nginx configs, and more.

๐Ÿ” Root Cause: PowerShell default encoding is not UTF-8. Set-Content and the -replace operator change file encoding. Also, $uri and $host are PowerShell built-in variables โ€” when passing Nginx configs over SSH, they get substituted with empty strings.

โœ… Fix: Switched to Python scripts for file writing, or used OpenClaw write tool (handles UTF-8 automatically).

๐Ÿ›ก๏ธ How to Avoid:

1. Never use Set-Content for files with Chinese characters

2. Use Python: with open(path, 'w', encoding='utf-8') as f: f.write(content)

3. Do not use PowerShell to transfer Nginx configs โ€” write locally then SCP upload

4. Verify after writing: python -c "open('file').read()" to confirm no garbling