KomuraSoft LLC
Chapter 4

Shift_JIS, Japan's legacy encoding — dame-moji and CP932

Shift_JIS lets second bytes intrude into the ASCII range by design. Understand from that structure the dame-moji problem it spawns, plus half-width kana, CP932, and why the encoding remains in service.

Typing "ソフト" breaks the system — a bug that sounds made up but is real

Save the word "ソフト" (Japanese for "soft/software") in an old business system, and for some reason only that row's data collapses. Create a folder whose path contains "表" and a certain tool starts failing. — The world of Shift_JIS is full of lore about such seemingly occult malfunctions. The goal of this chapter is to be able to explain them from the structure.

Shift_JIS — the legacy encoding that carried Japanese text before Unicode — was created to pack Japanese in alongside ASCII. ASCII stays 1 byte; full-width characters take 2 bytes.

ASCII
1 byte, 0x00–0x7F. Letters and digits unchanged
Half-width kana
1 byte, 0xA1–0xDF (アイウエオ…). An inheritance from the telegraph era
Full-width characters
2 bytes: lead byte 0x81–0x9F, 0xE0–0xFC + second byte 0x40–0x7E, 0x80–0xFC

The problem is the second byte's range. 0x40–0x7E is wholesale identical to the values of ASCII letters and symbols. Take the trailing byte of a full-width character on its own and it cannot be told apart from an ASCII symbol. The guarantee we saw in UTF-8 last chapter — every byte of a multi-byte character is 0x80 or above — simply does not exist here.

Diagram of Shift_JIS's 2-byte structure showing how the second byte 0x5C of 表 (95 5C) collides with the ASCII backslash

The second byte of "表", 0x5C, is a backslash in ASCII. To a program scanning byte-by-byte, the tail half of "表" looks like a symbol.

Dame-moji — the second-byte 0x5C collision

ASCII 0x5C is the backslash \ (in Japanese environments it is often displayed as a yen sign). In many programming languages and configuration formats it serves as the escape character meaning "treat the next character specially".

Now look at the Shift_JIS kanji "表". Its bytes are 95 5Cthe second byte is exactly 0x5C. A processor that scans strings byte-by-byte without awareness of Shift_JIS mistakes the 5C after 95 for a standalone backslash and consumes the following byte as an escape. Result: the tail of "表" is eaten, a character goes missing, and the interpretation of everything downstream shifts in a chain reaction — the true identity of the "occult bugs" above.

Characters whose second byte is 0x5C are numerous — "" (83 5C), "" (94 5C), "" (95 5C), "十", "予", "構", and more — and are known colloquially as dame-moji ("no-good characters"). All of them occur naturally in everyday Japanese, producing failures with maddeningly elusive reproduction conditions: "it only breaks with certain words". Beyond 0x5C, combinations where the second byte lands on " (0x22) or | (0x7C) can cause the same class of trouble.

Quiz 4-1 — The 2-byte structure and dame-moji

From Shift_JIS's structure, derive why only certain characters cause trouble.

Q1. Which statement correctly describes the structure of Shift_JIS?

Q2. In Shift_JIS the kanji '表' is the 2 bytes 95 5C. Passing a string containing it through a processor that treats 0x5C as an escape character (backslash) can corrupt it. Why?

Q3. Which combination is a correct example of so-called 'dame-moji' (troublemaker characters)?

CP932 — a dialect that calls itself "Shift_JIS"

One more piece of field knowledge: vendor-specific characters. Circled digits like ①, ㈱, Roman numerals like Ⅱ, "髙" (the "ladder" variant of 高) — none of these were in the original JIS character set; manufacturers added them independently. Windows adopted them into an extended variant, CP932, and uses it under the name "Shift_JIS".

In other words, most of what the world calls "Shift_JIS files" are, strictly speaking, CP932. Multiple subtly different tables answer to the same name — the root of nasty situations where data containing ① fails strict Shift_JIS conversion, or different environments garble different characters. The practical tip: in any Shift_JIS-related incident, suspect that the real table is CP932.

Why Shift_JIS is nonetheless still in service

The web has essentially unified on UTF-8. Shift_JIS (CP932) survives regardless, because migrating an encoding is not a problem you can solve by changing only your own side. Until every counterpart you exchange files with — Excel's legacy-format CSV, long-running core business systems, fixed-length file interfaces in finance and government — moves in step, the old encoding lingers at the handover points.

So this course treats Shift_JIS not as a relic but as an active suspect that still turns up in deductions. Reading a UTF-8 file as Shift_JIS, reading a Shift_JIS file as UTF-8 — telling these two misreading directions apart is the main event of the final exercises in Chapter 7.

Quiz 4-2 — Half-width kana, CP932, and why it survives

Round out the practical knowledge around Shift_JIS.

Q4. Which statement about half-width kana (アイウエオ…) in Shift_JIS is correct?

Q5. Which statement correctly describes the relationship between CP932 and Shift_JIS?

Q6. Even now that UTF-8 is the standard, situations requiring Shift_JIS (CP932) remain. Which is the most fitting reason?

Key takeaways from this chapter

  • Shift_JIS is ASCII in 1 byte + full-width in 2 bytes, but second bytes intrude into the ASCII range (0x40–0x7E)
  • Dame-moji = characters whose second byte lands on a symbol such as 0x5C (ソ 83 5C, 能 94 5C, 表 95 5C, …). They collide with escape processing and corrupt data
  • Half-width kana are single bytes 0xA1–0xDF. What Windows calls "Shift_JIS" is really CP932, with vendor characters added
  • Excel CSV and legacy interfaces keep it in service today. As a suspect in misreading cases, the relationship continues

Next: UTF-16, the other major Unicode encoding. This time the trap is not byte counts but how characters are counted.