【问题标题】:Is there way to check charset encoding of .txt file with Java?有没有办法用Java检查.txt文件的字符集编码?
【发布时间】:2012-06-16 20:39:03
【问题描述】:

有没有办法检查文本文件 (.txt) 是用 Unicode 编码还是用 Java 编码的 UTF-8?

【问题讨论】:

    标签: java unicode utf-8 character-encoding file-encodings


    【解决方案1】:

    您无法绝对确定在一般情况下使用哪种字符集。我发现这是一本好书。

    http://illegalargumentexception.blogspot.co.uk/2009/05/java-rough-guide-to-character-encoding.html

    尤其是自动检测编码部分。

    【讨论】:

      【解决方案2】:

      嗯,理论上,你怎么知道它是不是 unicode?​​p>

      这是真正的问题。 说实话,你无法知道,但你可以做出一个不错的猜测。

      见: Java : How to determine the correct charset encoding of a stream 了解更多详情。 :)

      【讨论】:

        猜你喜欢
        • 2011-08-29
        • 1970-01-01
        • 2014-04-10
        • 2020-12-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-06-23
        • 2017-02-20
        相关资源
        最近更新 更多