Home/Troubleshooting/Mac terminal shows non-English text as garbled characters, question marks or backslash numbers

Mac terminal shows non-English text as garbled characters, question marks or backslash numbers

Updated · airankrush

Symptom

With ls or cat, file names and content containing non-ASCII characters (accented letters, non-Latin scripts) show as question marks, boxes or garbage. In git status, such paths turn into backslashes and digits like \346\226\207. Or the characters display correctly, but the cursor lands in the wrong place when you type and delete.

Possible causes (most common first)

  1. The locale environment variables LANG and LC_ALL are unset or set to C. Shells started through remote login, scheduled jobs or certain tools often come without them.
  2. By default git treats bytes above 0x80 in paths as “unusual” characters and displays them escaped as octal. This is not corruption; the file itself is fine.
  3. The text encoding of the Terminal profile was changed to something other than UTF-8.
  4. The file itself is not UTF-8 encoded, for example an old text file brought over from Windows.

Troubleshooting steps (easiest first)

  1. Check the locale first

    Run locale in Terminal. If LANG and LC_CTYPE in the output are empty or C, this is the cause. Add the line export LANG=en_US.UTF-8 to ~/.zshrc (to get command-line messages in another language, use that language's locale name with the same .UTF-8 ending), then open a new terminal and try again. The part that matters is the UTF-8 at the end; the first half only decides the language of messages.

  2. git paths turned into numbers: change one setting

    Run git config --global core.quotePath false. According to the description of core.quotePath in the official git documentation, with it set to false, bytes above 0x80 are no longer treated as unusual characters and non-ASCII paths are shown as they are.

  3. Check the terminal's text encoding

    In the Terminal app, open Settings → Profiles, select the profile in use, and on the Advanced tab, in the International section, confirm that the text encoding is Unicode (UTF-8) and that “Set locale environment variables on startup” is ticked. See Apple's Terminal User Guide. These settings apply only to the selected profile. With another terminal such as iTerm2, look for the matching options in its own settings.

  4. Handle tmux and remote login separately

    If text is garbled only inside tmux, make sure the locale variables are set before tmux starts, then exit all old sessions and restart the tmux server. If it is garbled in a shell entered through remote login, that side most likely did not read your configuration file; put the export line in ~/.zprofile, which login shells read as well.

  5. Only one file is garbled: it is the file's encoding

    If other non-ASCII text displays correctly and only one file's content is garbled, the problem is the file. Use file followed by the file name to see its encoding, then convert it with iconv -f WINDOWS-1252 -t UTF-8 old.txt > new.txt, replacing WINDOWS-1252 with the actual source encoding.

When to contact support directly

This is a configuration issue in your own user environment. It normally does not need support and has nothing to do with a machine fault. The exceptions: non-Latin text shows as boxes in every app on the remote desktop (a font may be missing or the system language resources may be faulty), or non-Latin text pasted into the remote desktop turns into garbage (a clipboard issue in the remote-access app). In those cases contact support on Contact support with your machine ID, the remote connection method you use, the output of locale and a screenshot.

Pricing and availability: see the plans page · Help center (中文) · Refund policy (中文) · Telegram Contact support

Back to home · All troubleshooting pages