如何确定 OS X 中的文件编码? [英] How do I determine file encoding in OS X?
问题描述
我正在尝试将一些 UTF-8 字符输入到 TextMate (它说它的默认编码是 UTF-8),但 LaTeX 似乎不理解它们.
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.
运行 cat my_file.tex
在终端中正确显示字符.运行 ls -al
显示了我以前从未见过的东西:文件列表中的@":
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
(而且,是的,我在 LaTeX 中使用 usepackage[utf8]{inputenc}
.)
(And, yes, I'm using usepackage[utf8]{inputenc}
in the LaTeX.)
我找到了 iconv
,但这似乎无法告诉我编码是什么——它只会在我弄清楚后才会转换.
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.
推荐答案
@
表示该文件具有与其关联的扩展文件属性.您可以使用 getxattr()
函数查询它们.
The @
means that the file has extended file attributes associated with it. You can query them using the getxattr()
function.
没有确定的方法来检测文件的编码.阅读这个答案,它解释了原因.
There's no definite way to detect the encoding of a file. Read this answer, it explains why.
有一个命令行工具 enca,可以尝试猜测编码.你可能想看看.
There's a command line tool, enca, that attempts to guess the encoding. You might want to check it out.
这篇关于如何确定 OS X 中的文件编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!