I'm having problems dealing with accented characters in file names in the Terminal. Consider the following:
$ touch leão.png
$ ls > test.txt
$ open -a TextWrangler test.txt
The accented characters in test.txt
are incorrect. Here are some possibly relevant facts:
- I'm using Terminal with the default settings; the character encoding is set to UTF-8 and "Set locale environment variables on startup" is checked.
the output of
locale
in the shell is:LANG="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_CTYPE="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_ALL="en_US.UTF-8"
TextWrangler's default encoding is UTF-8; trying to reopen the file in any other encoding just makes matters worse.
- I'm running OS 10.6.8.
Update
In response to the comments, here is some more information:
The output of
od -tx1 test.txt
is:0000000 6c 65 61 cc 83 6f 2e 70 6e 67 0a 74 65 73 74 2e 0000020 74 78 74 0a 0000024
- If I do
echo leão.png > test2.txt
the text shows correctly in TextWrangler - Opening
test.txt
in TextEdit displays:leaÃÉo.png
- Opening
test.txt
in jEdit displays:leaÃÉo.png
- Opening
test.txt
in AlphaX displays:leaÃÉo.png
- Opening
test.txt
inemacs
from within terminal displays:leão.png
I'd really like to be able to work with non-ASCII filenames from within the shell. How can I get this to work?
od -tx1 test.txt
? What do you see in TextWrangler if you doecho leão >test2.txt
? What do you see if you opentest.txt
in other editors?