A complete example, start to finish
A Japanese sales export saved as Shift_JIS by Excel. Below: what it looks like when read with the wrong encoding, what the repaired file contains, and the report that goes with it. Every byte here was produced by running the tool on the file, not typed by hand.
1. What arrives: the same bytes, read as UTF-8
| 1 | ���i�R�[�h,���i��,�P��,����,�S�� |
| 2 | A-1001,��i�X�Y�j,120,30,�c�� |
| 3 | A-1002,�݂���i���Q�Y�j,80,45,���� |
| 4 | B-2001,�� 500ml,150,12,��� |
| 5 | B-2002,�ق����� 500ml,150,8,��� |
| 6 | C-3001,�̂�ٓ�,450,20,���� |
Read as Windows-1252 instead — the other common way this lands — the same file looks like this:
| 1 | �¤•iƒR�[ƒh,�¤•i–¼,’P‰¿,�”—Ê,’S“– |
| 2 | A-1001,‚è‚ñ‚²�i�Â�XŽY�j,120,30,“c’† |
| 3 | A-1002,‚Ý‚©‚ñ�iˆ¤•QŽY�j,80,45,�²“¡ |
| 4 | B-2001,—Î’ƒ 500ml,150,12,—é–Ø |
| 5 | B-2002,‚Ù‚¤‚¶’ƒ 500ml,150,8,—é–Ø |
| 6 | C-3001,‚Ì‚è•Ù“–,450,20,�‚‹´ |
2. What comes back
| 1 | 商品コード,商品名,単価,数量,担当 A-1001,りんご(青森産),120,30,田中 A-1002,みかん(愛媛産),80,45,佐藤 B-2001,緑茶 500ml,150,12,鈴木 B-2002,ほうじ茶 500ml,150,8,鈴木 C-3001,のり弁当,450,20,高橋 |
3. The report that ships with it
# Encoding repair report - file: `sales_sjis.csv` (201 bytes) - sha256 (input): `8d305b6203e018338d7277d5e4b61d0106f7e3c7cf57b983196a189f9352c197` - result: `sales.utf8.csv` - sha256 (output): `670d5b5dd7499f5e13138b05d8d48d6c741588f002bd06e54003e622daac64cd` - encoding identified: **cp932** (score 114.1) - U+FFFD present: no - ambiguous: no ## How the encoding was chosen Candidates are scored, not guessed: U+FFFD (lost bytes), private-use characters (invented characters), words that mix Latin and CJK, halfwidth katakana, and the share of common CJK characters all move the score. Full rules: `mojibake_repair/core.py`. | encoding | score | note | |---|---|---| | cp932 | 114.1 | | | gb18030 | 100.0 | | | cp1252 | 90.4 | contains U+FFFD: original bytes are already lost for those characters | ## Changed lines (6 of 6) | line | as read (wrong) | repaired | |---|---|---| | 1 | `���i�R�[�h,���i��,�P��,����,�S��` | `商品コード,商品名,単価,数量,担当` | | 2 | `A-1001,��i�X�Y�j,120,30,�c��` | `A-1001,りんご(青森産),120,30,田中` | | 3 | `A-1002,�݂���i���Q�Y�j,80,45,����` | `A-1002,みかん(愛媛産),80,45,佐藤` | | 4 | `B-2001,�Β� 500ml,150,12,���` | `B-2001,緑茶 500ml,150,12,鈴木` | | 5 | `B-2002,�ق����� 500ml,150,8,���` | `B-2002,ほうじ茶 500ml,150,8,鈴木` | | 6 | `C-3001,�̂�ٓ�,450,20,����` | `C-3001,のり弁当,450,20,高橋` | --- Produced with `mojibake-repair` (MIT, https://github.com/barnascuhel972-arch/mojibake-repair). Anyone can reproduce every number above by running the same command on the same input file.
4. Check it yourself
Download the two files and open the verifier. It decodes the original with six encodings and reports which one reproduces the repaired text exactly — that is the proof that nothing was invented or re-typed. Same rule as mojibake-repair --verify.
- sales_sjis.csv (the original bytes)
- sales.utf8.csv (the repaired file)
- report.md
- make_example.py — regenerates all three
Your file, same treatment: $10, paid only if it reads correctly.
Send a file up to 1 MB (or 20 rows of it) and you get the repaired file, this report, and the verifier link. Order on uGig (card or USDC) or open an issue.