◉CLAUDE LABJP
●2.1.301 — Adds the vim % motion, LaTeX math rendering in the VS Code panel, and a retry-watchdog limit for usage-limit waits (10/15)●2.1.299 — Conversations over 200K tokens left idle about 54 minutes get compacted; MCP allow rules now match only the server they name●SONNET 4.5 — Retires on the Claude API on 11/30, 45 days left. Migrate to Sonnet 5.5●WINDOWS — Reports say hooks break silently only on Japanese-locale Windows; check the character encoding first●FAST MODE — Opus 5.5 fast mode is out of research preview and no longer needs the beta header (10/15)●NEW — I Put a Ten-Line Promise File at the To…●2.1.301 — Adds the vim % motion, LaTeX math rendering in the VS Code panel, and a retry-watchdog limit for usage-limit waits (10/15)●2.1.299 — Conversations over 200K tokens left idle about 54 minutes get compacted; MCP allow rules now match only the server they name●SONNET 4.5 — Retires on the Claude API on 11/30, 45 days left. Migrate to Sonnet 5.5●WINDOWS — Reports say hooks break silently only on Japanese-locale Windows; check the character encoding first●FAST MODE — Opus 5.5 fast mode is out of research preview and no longer needs the beta header (10/15)●NEW — I Put a Ten-Line Promise File at the To…
Articles/Claude Code
⟐ Claude Code/2026-05-26Intermediate

Fixing Garbled Japanese Files in Claude Code — Identifying Shift-JIS vs UTF-8 and Converting Safely

When the Read tool spits out characters like 縺ゅ>縺ゅ> instead of Japanese, the file is almost always Shift-JIS or EUC-JP being misread as UTF-8. Here is a practical workflow to detect the real encoding and convert it for Claude Code, drawn from running a Japanese wallpaper app since 2014.

claude-code132troubleshooting92encoding3japaneseshift-jisutf-8

I am Hirokawa, an indie developer who has been shipping mobile apps since 1997 as a teenager and full-time since 2014, with cumulative downloads now past 50 million. A surprising amount of that workload involves Japanese CSVs and legacy Windows logs that predate UTF-8. When I started piping those files into Claude Code, the Read tool would return rows of 縺ゅ>縺ゅ> and 繧定ェュ縺ソ instead of readable text.

The cause is almost always encoding. Claude Code reads files as UTF-8, so Shift-JIS, CP932, EUC-JP, and BOM-prefixed UTF-8 files all corrupt at the Read step. Overwriting with the Edit tool while the file is still being misread is the worst thing you can do — it will destroy the original bytes. The reliable workflow is: detect, convert to a UTF-8 copy, verify, then read. This article walks through exactly that, with the commands I keep in my own claude.md.

Recognizing the garble — what each pattern usually means

You can often guess the original encoding just by looking at the broken output. A few common patterns:

  • Strings dominated by 縺, 繧, ヲ such as 縺ゅ>縺ゅ> → originally UTF-8 misread as Shift-JIS, or the inverse. The original bytes are usually still intact.
  • Sequences of half-width kana dots like ・ア・ア・ア → originally Shift-JIS read as UTF-8. Very common in terminals.
  • First three bytes are EF BB BF → UTF-8 with BOM. Most editors hide it, but CSV parsers and shell scripts often choke on the invisible prefix.
  • ASCII text is fine but Japanese characters collapse → multibyte boundary corruption.

I have a folder of release notes for an older app that is still saved as EUC-JP. Once I added a ### Encoding sanity check section to that project's claude.md, the time-to-recover dropped from "half a coffee" to under a minute.

A one-minute detection routine

These commands cover almost every Japanese file you will encounter in the wild.

# 1. Quick check using file (macOS / Linux built-in)
file -bi notes_legacy.csv
# Possible outputs:
#   text/plain; charset=utf-8
#   text/plain; charset=iso-8859-1   ← classic "unknown 8bit", usually Shift-JIS
#   text/plain; charset=us-ascii
 
# 2. nkf -g, the Japanese-aware detector (brew install nkf / apt install nkf)
nkf -g notes_legacy.csv
# Possible outputs:
#   Shift_JIS
#   EUC-JP
#   UTF-8
 
# 3. Look at raw header bytes (the most reliable BOM check)
head -c 16 notes_legacy.csv | hexdump -C
# Leading EF BB BF → UTF-8 with BOM
# Leading FF FE     → UTF-16 LE
# Leading FE FF     → UTF-16 BE

In practice, when file -bi reports iso-8859-1, the file is Shift-JIS about 90% of the time. When it reports unknown-8bit, EUC-JP is still in play, so I reach for nkf -g for a second opinion. If nkf is not installed on the machine Claude Code is running on, install it with brew install nkf on macOS or apt install nkf on Linux.

Convert to UTF-8 before handing the file to the Read tool

Always produce a UTF-8 copy under a new name instead of overwriting the original. Keeping the original around means a botched conversion is a one-second rollback, not a "where is the backup" emergency.

# Shift-JIS → UTF-8 (the most common case)
iconv -f CP932 -t UTF-8 notes_legacy.csv > notes_legacy.utf8.csv
 
# Why CP932 instead of Shift_JIS: Windows-origin "Shift-JIS" files are technically
# CP932 (Microsoft's extended variant). Specifying Shift_JIS will fail on platform
# extensions like ①, ㈱, and 髙 that are common in Japanese business data.
 
# EUC-JP → UTF-8
iconv -f EUC-JP -t UTF-8 old_release_notes.txt > old_release_notes.utf8.txt
 
# Strip the UTF-8 BOM (when CSV parsers stumble on the leading prefix)
sed -i.bak '1s/^\xEF\xBB\xBF//' data.csv
 
# Add //TRANSLIT//IGNORE to tolerate untranslatable characters
iconv -f CP932 -t UTF-8//TRANSLIT//IGNORE notes_legacy.csv > notes_legacy.utf8.csv

Almost every unknown character error from iconv comes from platform-dependent characters: enclosed numerals, Roman numerals, archaic kanji forms. Adding //TRANSLIT//IGNORE quietly drops anything that cannot be represented, which is usually the right call for legacy business CSVs.

Before pointing Claude Code's Read tool at the new file, verify by eye.

head -3 notes_legacy.utf8.csv
file -bi notes_legacy.utf8.csv  # expect: charset=utf-8

Batch conversion workflow for Claude Code

When several files need converting, I drive it from a single Bash call. Writing this with concise output makes it easy for Claude to summarize.

# Convert every Shift-JIS or EUC-JP file under .legacy/ into .utf8/
mkdir -p .utf8
for f in .legacy/*.csv; do
  out=".utf8/$(basename "$f")"
  enc=$(nkf -g "$f")
  case "$enc" in
    "Shift_JIS")
      iconv -f CP932 -t UTF-8//TRANSLIT "$f" > "$out" && echo "OK   sjis  $f"
      ;;
    "EUC-JP")
      iconv -f EUC-JP -t UTF-8//TRANSLIT "$f" > "$out" && echo "OK   eucjp $f"
      ;;
    "UTF-8"|"BINARY")
      cp "$f" "$out" && echo "SKIP utf8  $f"
      ;;
    *)
      echo "WARN $enc $f"
      ;;
  esac
done

I ran this script over roughly 120 category-management CSV files for my wallpaper app, which had Shift-JIS and UTF-8 mixed together after years of edits across Windows and macOS. The whole archive was clean by morning, and asking Claude Code to dedupe categories under .utf8/ worked on the first try.

Four more pitfalls to rule out before you give up

  1. Git's core.autocrlf is interfering: A Windows-side true paired with a macOS / Linux false can desync both newlines and encoding. Place a .gitattributes at the project root with *.csv text working-tree-encoding=CP932 eol=crlf to let Git handle the conversion automatically.
  2. The CSV delimiter is \t or ;: If Japanese itself looks fine but the columns are mangled, the issue may not be encoding at all. head -1 to inspect the first row.
  3. Claude Code's Bash environment expects UTF-8: Without LANG=ja_JP.UTF-8, even echo output can garble. Run locale to check, and if needed export LANG=ja_JP.UTF-8 LC_ALL=ja_JP.UTF-8.
  4. An editor is re-adding the BOM: Check that VSCode is not configured to "Save with BOM", or pin it down with .editorconfig's charset = utf-8.

I once spent an hour on an App Store Connect revenue CSV that arrived in CP932, fighting pandas.read_csv ParserError until I finally ran file -bi and realized I was reading it as the wrong encoding the whole time. Making file -bi the first command saved me from repeating that mistake.

What to try next

When you hit garbled Japanese in Claude Code, run through these four steps in order:

  1. file -bi <file> to fingerprint the encoding
  2. If unsure, nkf -g for a second opinion
  3. iconv -f CP932 -t UTF-8//TRANSLIT//IGNORE to produce a UTF-8 copy under a new name
  4. Sanity-check with head and file -bi before pointing the Read tool at it

Once legacy files become safe to load, the range of work Claude Code can do over old Japanese assets — analysis, refactoring, migration — opens up considerably. I hope this saves you some of the time I burned figuring it out.

Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

⟐ Claude Code2026-05-24
When Claude Code's Sequential Edits Cascade into Failure — Fixing 'old_string not found' and 'not unique' on the Same File
Run several Edits against the same file in one turn and the second or third one suddenly fails with 'not found' or 'not unique'. The cause is order-dependence inside a single context snapshot, and a Read + scoped patches usually rescue it.
⟐ Claude Code2026-05-10
When Claude Code's Read Doesn't Reach the End of a File — Catching the PARTIAL view Notice and Sizing offset/limit
When Read returns only part of a large file, Claude Code says so with a PARTIAL view notice. Here is how to catch it, and how to size offset and limit by byte budget rather than line count, with measurements from my own sandbox.
⟐ Claude Code2026-05-10
Why Claude Code's Glob and Grep Return Zero Results
When Claude Code's Glob or Grep tool returns no matches even though the files clearly exist, the cause is almost always one of four things. Here's how to triage.