Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I use Quick Look in the Finder on a text file, it'll inevitably render garbled because it treats it as MacRoman.

Can I do something to make it always use UTF-8, or, even better, be ever so slightly smart about encoding detection?

Maybe not all my text files are UTF-8. But I'm damn sure not a single one is MacRoman. Some people at Apple are still using OS 9 I guess.

share|improve this question
up vote 6 down vote accepted

It's a file attribute problem. See here, at the end, two links explaining it:

Basically, if you execute this: xattr -w 'UTF-8;134217984' yourfile.txt your file will appear correctly in QuickLook.

In my opinion it has to do more with the editor and the way it saves the file than with QuickLook.

share|improve this answer
In my opinion, the OS defaulting to MacRoman while the world has moved on is asinine. – kch Aug 3 '10 at 11:49
I guess now I need a way to run that for every text file I create. fsevents and Folder Actions come to mind. Would be nice if TextMate had post-save hooks too. – kch Aug 3 '10 at 11:52
Why don't you just save it as UTF-8 in TextMate? – mipadi Aug 3 '10 at 14:20
I do, that's indeed the problem. QuickLook thinks it's MacRoman anyway. Hence the garbling. – kch Aug 3 '10 at 15:01

I wrote a little script that taps fsevents and sets the xattr when a file is saved within my home.

I also reveal the file's extension, which is unrelated to this question.

Check out the script here:

The script must be constantly running, so a launchd job file would be most welcome.

Also, see my comment about using ~/.CFUserTextEncoding here.

share|improve this answer
Speaking of launchd, WatchPaths and QueueDirectories may do the job without my needing to tap fsevents myself. – kch Aug 3 '10 at 14:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .