agentsclimarketplace

File encoding

Skill longhun12346/artifact-skills/skills/file-encoding

Transparent encoding handling for Windows C++ projects. Automatically converts non-UTF-8 files (ANSI/GBK/UTF-8 BOM/UTF-16 LE BOM) before Edit/Write/Read and restores encoding after — no special commands needed.From its SKILL.md

Install
npx -y skills add longhun12346/artifact-skills --skill file-encoding

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

5.7 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it

file-encoding

How it works

This skill installs transparent hooks that handle file encoding automatically:

  1. Before Edit/Write/Read: detects encoding → converts non-UTF-8 files to UTF-8 in place
  2. Claude's tool runs normally on the UTF-8 file
  3. After Edit/Write/Read: converts back to original encoding

You don't need to do anything special. Just use Edit/Write/Read normally — the hooks handle encoding invisibly.

When it activates

  • Only on monitored extensions: .cpp .h .hpp .c .cc .cxx .rc .bat .nsi .ini .xml
  • Only when encoding is non-UTF-8 (GBK, Shift-JIS, EUC-KR, Big5, UTF-8 BOM, UTF-16 LE BOM)
  • UTF-8 files pass through with minimal overhead (~70ms subprocess startup)

Supported encodings

Auto-converted (hook converts to/from UTF-8)

CategoryEncodingsTypical file typesDetection reliability
CJK multibytegbk, shift-jis, euc-kr, big5.cpp .h .rc .batHigh (distinctive byte patterns)
Cyrillicwindows-1251.cpp .h .rcHigh (chardet reliable for Cyrillic)
Unicode BOMutf-8-bom.nsiExact (BOM prefix)
UTF-16utf-16-le-bom, utf-16-be-bom.iniExact (BOM prefix)

Pass-through (no conversion needed)

CategoryEncodingsReason
UTF-8 / ASCIIutf-8, asciiClaude native support
Western single-bytewindows-1252, windows-1250, iso-8859-1/2High bytes rare in source code
Other single-bytewindows-1253~1258Same; detection unreliable between these
BinarybinaryNot text

Design rationale

  • CJK + Cyrillic → convert: byte patterns distinctive, chardet reliable, non-ASCII content is substantial (Claude cannot understand without conversion)
  • Western single-byte → pass-through: hard to distinguish between these encodings reliably; incorrect conversion risks data corruption; non-ASCII bytes rare in source code (occasional accented chars in comments)
  • If chardet is not installed, heuristic fallback may misidentify Shift-JIS / EUC-KR as GBK on Chinese Windows. Install chardet for reliable results.

New file creation

The hooks only convert existing files. When creating new files with Write, the file will be UTF-8 by default.

If the project requires a different encoding for new files (e.g., GBK for .cpp), use encoding_utils.py:

# Check what encoding siblings use
python ${CLAUDE_SKILL_DIR}/scripts/encoding_utils.py detect "existing_file.cpp"

# Write new file with that encoding
echo "content" | python ${CLAUDE_SKILL_DIR}/scripts/encoding_utils.py safe-write "new_file.cpp" --enc gbk

Manual commands (encoding_utils.py)

For operations outside the hook cycle (batch conversion, explicit encoding control):

python ${CLAUDE_SKILL_DIR}/scripts/encoding_utils.py detect <file>
python ${CLAUDE_SKILL_DIR}/scripts/encoding_utils.py read <file> [--enc E]
python ${CLAUDE_SKILL_DIR}/scripts/encoding_utils.py write <file> --enc E
python ${CLAUDE_SKILL_DIR}/scripts/encoding_utils.py convert <file> --to E [--enc F]
python ${CLAUDE_SKILL_DIR}/scripts/encoding_utils.py safe-write <file> [--enc E]

Crash recovery

If Claude Code crashes mid-operation (file left in UTF-8 state):

python ${CLAUDE_SKILL_DIR}/scripts/encoding_transparent.py recover

Installation

python ${CLAUDE_SKILL_DIR}/scripts/install_hook.py           # install hooks
python ${CLAUDE_SKILL_DIR}/scripts/install_hook.py --check   # verify installation
python ${CLAUDE_SKILL_DIR}/scripts/install_hook.py --uninstall  # remove hooks

Limitations

  1. New files default to UTF-8 — Write creates files as UTF-8. If the project requires GBK/other encoding for new .cpp/.h files, you must explicitly use encoding_utils.py safe-write --enc.

  2. Concurrent sessions — File locking prevents state corruption, but two sessions converting the same file simultaneously may still produce unexpected results. In practice this is rare (one session per project).

  3. Process kill without PostToolUse — If Claude Code is forcefully killed between Pre and Post, the file remains in temporary UTF-8 state. Run encoding_transparent.py recover to restore, or the file will stay UTF-8 until the next Pre/Post cycle.

  4. Only monitored extensions — Files outside .cpp/.h/.hpp/.c/.cc/.cxx/.rc/.bat/.nsi/.ini/.xml are not handled, even if they have non-UTF-8 encoding. Add extensions to MONITORED_EXTENSIONS in encoding_transparent.py if needed.

  5. Encoding detection without chardet — Without chardet, detection uses a heuristic fallback that tries codecs in order. This can misidentify Shift-JIS/EUC-KR as GBK on Chinese Windows. Install chardet for reliable results.

Debugging

Set ENCODING_TRANSPARENT_DEBUG=1 to see conversion details on stderr:

set ENCODING_TRANSPARENT_DEBUG=1 && claude

Tested environment

ItemDetail
AgentClaude Code (Claude Sonnet 4 / Opus 4)
OSWindows 10/11 x64
Python2.7, 3.8+
chardet5.x (recommended)
Test projectpc-international (C++ / NSIS, mixed GBK + UTF-8 BOM + UTF-16 LE BOM)

Linux / macOS not yet validated. The hook logic is platform-agnostic; only path separators and temp dir differ.

Requirements

  • Python 2.6+ or 3.x
  • Recommended: chardet for reliable encoding detection (pip install chardet)

What ships with it: 7 files

93.2 KB alongside SKILL.md, 5 of them executable

Keep looking

Skills are one crate of 326,367. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.