且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在objective-c中检测文本文件编码?

更新时间:2023-02-20 10:30:43

您可以使用 stringWithContentsOfFile:usedEncoding:error:除了新的字符串,它返回使用的编码。

You can use stringWithContentsOfFile:usedEncoding:error:, which returns, in addition to the new string, the encoding that was used.

我应该注意,这是一个启发式过程本质上 - 并不总是可能确定文件的字符编码。

I should note that this is a heuristic process by nature -- it's not always possible to determine the character encoding of a file.