encoding-guard

Enforces UTF-8 encoding for files and terminal output to prevent Chinese character mojibake.

Updated Apr 11, 2026
One-click install
npx skills add https://github.com/Coral5644/NekansModPack --skill encoding-guard-coral5644
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: encoding-guard
Source: https://github.com/Coral5644/NekansModPack/tree/main/.cursor/skills/encoding-guard
Command: npx skills add https://github.com/Coral5644/NekansModPack --skill encoding-guard-coral5644

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Chinese characters frequently appear as garbled text (mojibake) when files are saved in GBK/ANSI encodings or when Windows PowerShell terminals use non-UTF-8 code pages. This Skill eliminates that problem by enforcing UTF-8 encoding rules for every file operation and terminal command. ## Core Features & Use Cases - File Encoding Enforcement: Requires all new and edited files to be saved as UTF-8 (no BOM), with a mandatory # -*- coding: utf-8 -*- header for Python files. - Terminal Encoding Setup: Provides ready-to-run PowerShell commands that set console output encoding, plus PYTHONIOENCODING and PYTHONUTF8 environment variables for Python commands. - Git and File-Reading Guidance: Documents pre-configured Git encoding settings and shows how to read files explicitly as UTF-8 in PowerShell. - Use Case: Before running a Python script that prints Chinese log messages on Windows, apply the one-line UTF-8 setup command so the console displays the output correctly instead of garbled characters. ## Quick Start Before creating files or running commands that output Chinese text, apply the UTF-8 environment setup commands from this Skill and save all files in UTF-8 encoding.

Frequently Asked Questions about encoding-guard

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix Chinese characters showing as garbled text in PowerShell?▼

Set the console output encoding to UTF-8 before running commands by executing $env:LANG='en_US.UTF-8' and [Console]::OutputEncoding=[System.Text.UTF8Encoding]::new($false). This ensures Chinese output renders correctly in the terminal.

How do I make Python output UTF-8 on Windows?▼

Set the PYTHONIOENCODING environment variable to utf-8 and PYTHONUTF8 to 1 before running Python commands. Also include the # -*- coding: utf-8 -*- header at the top of each Python file.

What encoding should I use when saving files containing Chinese text?▼

Save all files in UTF-8 encoding without BOM. Avoid GBK, ANSI, or other legacy encodings, and convert existing GBK files containing Chinese to UTF-8 when editing them.

Why does Git show garbled Chinese characters in commit messages?▼

Git mojibake usually means the terminal encoding was not set before running the command. With i18n.commitEncoding=utf-8, i18n.logOutputEncoding=utf-8, and core.quotepath=false configured globally, running the UTF-8 console setup command resolves remaining display issues.

How do I read a UTF-8 file correctly in PowerShell?▼

Use [System.IO.File]::ReadAllText with an explicit UTF-8 encoding argument, such as [System.Text.UTF8Encoding]::new($false), instead of relying on default encoding detection which may misinterpret the file.