第三方统一类型标识符实现?

时间:2022-06-14 20:07:27

The madness of file extensions and MIME types and creator codes and magic numbers to determine file types is a huge mess. Coming from a background of Cocoa programming, I supposed I'm spoiled: in Tiger, OS X added a system called Uniform Type Identifiers (UTIs) that makes the entire process sane.

文件扩展名和MIME类型以及用于确定文件类型的创建者代码和幻数的疯狂是一个巨大的混乱。来自Cocoa编程的背景,我认为我被宠坏了:在Tiger中,OS X增加了一个名为统一类型标识符(UTI)的系统,使整个过程变得健全。

Given that I'm doing a bunch of web development in (insert your favorite web development environment here), is there anything similar that's not dependent on running OS X and - better yet - works in multiple programming languages?

鉴于我正在进行一系列的Web开发(在这里插入您最喜欢的Web开发环境),是否有类似的东西不依赖于运行OS X而且 - 更好的是 - 在多种编程语言中工作?

Right now, I'm using the file command on Linux to replicate some of the functionality, but it's just not the same. And, of course, everybody has their huge lookup tables, but nothing is centralized.

现在,我在Linux上使用file命令来复制一些功能,但它不一样。当然,每个人都有他们庞大的查找表,但没有什么是集中的。

Has anybody done this or run across this before?

有没有人这样做过或者之前遇到过这种情况?

1 个解决方案

#1


There just doesn't seem to be any such thing outside of OS X. The file command is the best that you can do on linux, all the file type identification systems I've seen on linux use it internally (when they aren't just using the file extension).

在OS X之外似乎没有任何这样的东西。文件命令是你可以在linux上做的最好的,我在linux上看到的所有文件类型识别系统都在内部使用它(当它们不是只是使用文件扩展名)。

In particular you can use file -i to output a MIME type rather than the plain human-readable strings.

特别是,您可以使用file -i输出MIME类型,而不是普通的人类可读字符串。

The UTI system seems to have a great deal of useful functionality, maybe if you could tell us what in particular you miss about it that the other methods you've found don't give you, it might be easier for us to find you something useful.

UTI系统似乎有很多有用的功能,也许如果你可以告诉我们你错过了什么,你发现的其他方法没有给你,我们可能更容易找到你的东西有用。

#1


There just doesn't seem to be any such thing outside of OS X. The file command is the best that you can do on linux, all the file type identification systems I've seen on linux use it internally (when they aren't just using the file extension).

在OS X之外似乎没有任何这样的东西。文件命令是你可以在linux上做的最好的,我在linux上看到的所有文件类型识别系统都在内部使用它(当它们不是只是使用文件扩展名)。

In particular you can use file -i to output a MIME type rather than the plain human-readable strings.

特别是,您可以使用file -i输出MIME类型,而不是普通的人类可读字符串。

The UTI system seems to have a great deal of useful functionality, maybe if you could tell us what in particular you miss about it that the other methods you've found don't give you, it might be easier for us to find you something useful.

UTI系统似乎有很多有用的功能,也许如果你可以告诉我们你错过了什么,你发现的其他方法没有给你,我们可能更容易找到你的东西有用。