A focused, idempotent, bidirectional charset transcoder for Windows source trees. Default output: UTF-8 without BOM.
中文 · Design · Maintainer guide · Rollout playbook · Full usage · Roadmap
Mixed-encoding source trees (GB18030 / UTF-8 / UTF-8 BOM / UTF-16) cause:
C4819 on English Windows / CIutf8-forge normalizes the tree in one idempotent pass, so you can safely enable /utf-8 afterwards.
--target utf-16le refuses content whose
first character is U+0000 — its output would be byte-identical to the UTF-32LE BOM and could never be re-read as
UTF-16. --target gb18030 refuses two content classes: U+E5E5 (the single scalar WHATWG’s gb18030 encoder cannot
map) and content whose gb18030 encoding would itself read back as different characters (1920 common hanzi, e.g.
一 → D2 BB, which re-reads as һ — the next run would silently rewrite the file; see USAGE §4.4)dep/, binaries, or build outputs.utf8forgeignore exclusions (auto-discovered)--config) with CLI > config > defaults precedencerayon)--url) reuses the same pipeline# From crates.io
cargo install utf8-forge
# From source
cargo install --path . --locked
# Or build in-tree
cargo build --release
# Binary: target/release/utf8-forge
Local-only build (no reqwest):
cargo build --release --no-default-features
# 1) Scan encoding distribution
utf8-forge scan --root D:\server --report scan.json
# 2) Dry-run: see what would change
utf8-forge convert --root D:\server --dry-run --report dry.json
# 3) Real conversion with backup
utf8-forge convert --root D:\server --backup-dir D:\backup\utf8-forge
# 4) Verify everything is UTF-8 without BOM
utf8-forge verify --root D:\server
# Optional: convert + verify in one pass
utf8-forge fix --root D:\server
Safety rule: scan → --dry-run → convert. Never skip step 2.
utf8-forge convert \
--url https://example.com/data/legacy.cpp \
--output ./legacy.cpp \
--target utf-8
--url reuses the exact same detection / transcoding pipeline; only the source of bytes changes. Size is capped by
--max-file-size (default 200 MiB).
Notes: --backup-dir cannot be combined with --url (fatal, exit 2), and neither can a --report path equal to the
output path (explicit or derived) — the report write would silently replace the fetched artifact. An oversized payload
fails with exit 1 and is not written. A write-protected destination file is refused exactly like tree mode (exit 1; the
destination is left untouched); so are symlinked and non-regular destinations (a FIFO would otherwise hang the
comparison read). When --output is omitted, a URL segment with an extension is kept, percent-decoded
(…/my%20file.cpp → my file.cpp); an extension-less segment gets .utf8 (…/foo → foo.utf8). Re-fetching
identical content reports unchanged and skips the write. The size cap is enforced during download — an oversized
payload aborts mid-stream and nothing is written. Bodyless responses (204/304/3xx without a location) and terminal
206 Partial Content are refused instead of writing an empty or truncated file, and an https:// request never
follows a redirect that downgrades to plain http:// (plain-http requests follow redirects freely).
| Command | Purpose | Writes? |
|---|---|---|
scan |
Encoding distribution report | ❌ |
convert |
Detect + transcode + atomic write | ✅ |
convert --url |
Fetch remote file and transcode | ✅ |
verify |
Assert all whitelisted files are UTF-8 no BOM | ❌ |
fix |
Convert + verify in one pass (exit 3 on gate failure) | ✅ |
diff |
Compare two JSON reports per path | ❌ |
See docs/USAGE.md for the full CLI reference and recipes.
C/C++ (.c .cc .cpp .cxx .h .hh .hpp .hxx .inl .ipp .tpp), .NET (.cs), JVM (.java .kt), Rust (.rs), Go (.go),
Python (.py), JS/TS (.js .jsx .ts .tsx), Shell (.sh .bash .ps1 .bat), Config (.json .yaml .toml .ini .xml), Docs
(.md .txt .rst), Protocol (.proto).
Not included by default: .rc, .sln, .vcxproj — enable with --include-rc / --include-msbuild.
Excluded by default: dep/, _tools/, .svn/, .git/, build/, temp/, OutputFile*/, node_modules/,
__pycache__/, etc.
utf8-forge tracks Rust stable (edition 2024). It uses stable language features that require a reasonably recent
toolchain — any stable Rust 1.88 or newer builds the crate. No MSRV is pinned; CI validates the latest stable
toolchain on every push.
Apache License, Version 2.0 only. Copyright © 2026 houseme. See LICENSE for the full text.