开发者

In Java can I ask the system to tell me the charset of a file?

There are questions like this, that are about guessing charset/encode of 开发者_开发知识库a file. But is there a method in Java to ask the system to tell me before try to guess?


No, there isn't. That's exactly why those questions were asked.


How is "the system" supposed to know? If the encoding isn't declared in some sort of metadata somewhere, then educated guessing is the only thing that can be done.


There is no way for the system to know what encoding was used when the file was written. The system would need to try make an educated guess based on the file contents, same as you would do yourself from your application.

You will need to implement this yourself, or use an external library such as the ones described in the original question you referenced.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜