Displaying UTF-8 correctly in Leopard Terminal

Written . Tagged OS X.

On my fresh Leopard install, UTF-8 didn’t quite work in Terminal.

Update
After discussions with Allan who had noticed similar issues, it seems that this issue is due to some bug you may run into when customizing your region formats in the International preference pane; so see this post as a solution if you run into that as well. If you haven’t customized the formats, or you selected a region and later customized that, you probably don’t have this issue.

A file named täst was displayed by e.g. ls as

t??st

This was even after adding

1
export LC_CTYPE=sv_SE.UTF-8

as described in desp’s guide. You might want to set en_US.UTF-8 if you’re American, and so on.

Unchecking the “Set LANG environment variable on startup” checkbox in the Terminal settings, under the “Advanced” tab, fixes it though. I’ve tested this in both bash and zsh.

When the box is checked, the locale command returns (among other things)

1
2
LANG="UTF-8"
LC_CTYPE="C"

It seems to overwrite my LC_CTYPE. With it unchecked, I get

1
2
LANG=
LC_CTYPE="sv_SE.UTF-8"

and ls now displays

täst

as it should.