How do I determine file encoding in OS X?

James A. Rosen picture James A. Rosen · Feb 12, 2009 · Viewed 212k times · Source

I'm trying to enter some UTF-8 characters into a LaTeX file in TextMate (which says its default encoding is UTF-8), but LaTeX doesn't seem to understand them.

Running cat my_file.tex shows the characters properly in Terminal. Running ls -al shows something I've never seen before: an "@" by the file listing:

-rw-r--r--@  1 me      users      2021 Feb 11 18:05 my_file.tex

(And, yes, I'm using \usepackage[utf8]{inputenc} in the LaTeX.)

I've found iconv, but that doesn't seem to be able to tell me what the encoding is -- it'll only convert once I figure it out.

Answer

Tim picture Tim · Mar 17, 2010

Using the -I (that's a capital i) option on the file command seems to show the file encoding.

file -I {filename}