Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By ymonsterMITIn 1 marketplace
Keeps GBK, Big5 and Shift_JIS files and their CRLF line endings intact when Claude Code edits them. Hooks run on every Read, Edit and Write to convert files to UTF-8 and back, and it requires uv.
Trending plugins
7-day copy clicks
You run one by typing its /name in Claude Code.
2 cautions to review before installing
A hook runs when Claude writes or edits files
A command runs shell commands (! syntax) when you invoke it
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
1 marketplace, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Preserve non-UTF-8 file encodings and line endings when Claude Code edits your files.
Claude Code's Edit/Write tools always output UTF-8 with LF line endings. When editing files in GBK, Big5, Shift_JIS, or other legacy encodings, the original encoding is silently destroyed. CRLF line endings are also lost on Windows. The official response is "not planned".
Related issues: #6485, #7134, #28523, #38887.
PreToolUse (Read) PostToolUse (Edit/Write)
│ │
├─ binary check (binaryornot) ├─ read cached encoding + line ending
├─ detect encoding (chardet 5.x) ├─ convert UTF-8 → original encoding
├─ detect line ending (CRLF/LF) ├─ normalize line endings to original
├─ convert original → UTF-8 ├─ delete session cache
├─ save session cache └─ done
└─ Claude reads correct content
Conversion happens at Read time, before Claude Code loads the file into memory. This is critical — Claude Code interprets non-UTF-8 bytes as UTF-8, replacing invalid sequences with U+FFFD (irreversible). By converting to UTF-8 first, Claude sees correct content and edits cleanly.
pip install needed./plugin marketplace add ymonster/claude_encoding_guard
/plugin install encoding-guard
After installation, Read any non-UTF-8 file — Chinese characters should display correctly instead of garbled text.
A migration to chardet 7.x is being prototyped on the chardet7-preview branch. It drops the binaryornot dependency (chardet 7.x has built-in binary detection) and uses 0BSD-licensed chardet (vs LGPL on 5.x). Not recommended for daily use yet — see the branch's README for status and install instructions.
uv run --script: Plain uv run triggers project sync which closes the stdin pipe on Windows. --script skips project discovery.<tmpdir>/.cc_encoding_cache/<session_id>/ — no cross-session interference. Hooks act strictly on their own session's records; stale empty session dirs (>24h) are auto-removed, record-bearing dirs never are (see Crash Recovery).Recommended: use under version control as a fallback for binary misedits. We do our best to avoid editing binary files through multiple defensive layers (and in practice Claude Code rarely tries to edit a binary file anyway), but stray cases are always possible. We considered using local git stash as an automatic fallback but didn't want to interfere with the user's own git workflow (polluting stash list, reflog, etc.). So strongly recommended: use this plugin under git or another version control tool, so any misidentification can be safely rolled back.
Windows-1252 stale cache edge case. If cache deletion fails (e.g., antivirus lock) and the file's original Windows-1252 bytes happen to be valid UTF-8, the stale cache won't self-heal. This requires two unlikely conditions to coincide and doesn't affect CJK encodings (GBK/Big5/Shift_JIS bytes are not valid UTF-8).
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub ymonster/claude_encoding_guard --plugin encoding-guardPlugins from other owners that cover similar ground