4

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?


<rant>
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.
</rant>

kch
  • 2,272

2 Answers2

8

It's a file attribute problem. See here, at the end, two links explaining it: http://discussions.apple.com/thread.jspa?threadID=1479441&tstart=120

Basically, if you execute this: xattr -w com.apple.TextEncoding '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.

Alex
  • 1,865
0

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: http://gist.github.com/506382

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


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

kch
  • 2,272