How do I determine file encoding in OS X?

后端 未结 15 1002
死守一世寂寞
死守一世寂寞 2020-11-29 15:12

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.

Runn

15条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 15:36

    vim -c 'execute "silent !echo " . &fileencoding | q' {filename}
    

    aliased somewhere in my bash configuration as

    alias vic="vim -c 'execute \"silent \!echo \" . &fileencoding | q'"
    

    so I just type

    vic {filename}
    

    On my vanilla OSX Yosemite, it yields more precise results than "file -I":

    $ file -I pdfs/udocument0.pdf
    pdfs/udocument0.pdf: application/pdf; charset=binary
    $ vic pdfs/udocument0.pdf
    latin1
    $
    $ file -I pdfs/t0.pdf
    pdfs/t0.pdf: application/pdf; charset=us-ascii
    $ vic pdfs/t0.pdf
    utf-8
    

提交回复
热议问题