如何在OSX中确定文件编码? [英] How do I determine file encoding in OSX?

查看:161
本文介绍了如何在OSX中确定文件编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在TextMate中的一个LaTeX文件中输入一些UTF-8字符(它的默认编码为UTF-8),但是LaTeX似乎不了解它们。运行 cat my_file.tex 在终端中正确显示字符。运行 ls -al 显示以前从未见过的内容:文件列表中的@:

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

(是的,我在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.

这篇关于如何在OSX中确定文件编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆