|
Download i18n/i18n-0010.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 2.46 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/main/i18n/i18n-0010.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm/i18n/i18n-0010.jsonl
-
curl -L -o i18n-0010.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/main/i18n/i18n-0010.jsonl
2.46 kB
| {"type": "session", "harness": "opencode", "id": "i18n-0010", "name": "Mojibake definition and repair"} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert NLP engineer. You explain text-encoding failures precisely and give correct, minimal Python examples."}} | |
| {"type": "message", "message": {"role": "user", "content": "What is mojibake, where does the term come from, and how do I fix it when I see it?"}} | |
| {"type": "message", "message": {"role": "assistant", "content": "**Mojibake** (文字化け, Japanese for \"character transformation\") is garbled text produced by decoding bytes with the *wrong* character encoding. It is not a font problem and not missing glyphs — the bytes are intact, they were just interpreted under the wrong codec.\n\n**Origins:** the term comes from Japanese computing in the 1980s-90s, when Shift_JIS, EUC-JP and ISO-2022-JP coexisted and mail/news readers routinely guessed wrong, turning Japanese into garbage. It is now the general term for any such mis-decode, in any language.\n\n**How to recognize it:** the corruption has signatures of the (wrong, right) codec pair:\n\n| you see | actual text | what happened |\n|---|---|---|\n| Nguyá»…n | Nguyễn | UTF-8 bytes read as Windows-1252 |\n| Lê | Lê | UTF-8 bytes read as Windows-1252 |\n| ��� | 你好 | non-UTF-8 bytes read as UTF-8 with replacement |\n\n**Repair, reversible case:** decoders like cp1252 never fail on any byte, so no information is lost — re-encode with the *wrong* codec and decode with the *right* one:\n\n```python\ngarbled = \"Nguyá»…n\" # UTF-8 bytes misread as cp1252\nfixed = garbled.encode(\"cp1252\").decode(\"utf-8\")\nassert fixed == \"Nguyễn\"\nprint(fixed)\n```\n\n**Repair, lossy case:** if the wrong decode used `errors=\"replace\"`, every bad byte became U+FFFD and the original is unrecoverable from the string — go back to the raw bytes:\n\n```python\nraw = \"你好\".encode(\"gbk\") # b'\\xc4\\xe3\\xba\\xc3'\nseen = raw.decode(\"utf-8\", errors=\"replace\") # full of U+FFFD\nassert \"\\ufffd\" in seen # information lost; re-read the source bytes\ncorrect = raw.decode(\"gbk\")\nassert correct == \"你好\"\n```\n\n**Prevention beats repair:** always pass `encoding` explicitly when opening text (UTF-8 by default, `utf-8-sig` for unknown sources), and treat a sudden burst of `á», Ã, �` as an encoding bug, never as content to train on."}} | |