Java: Readers and Encodings

后端 未结 5 450
臣服心动
臣服心动 2020-12-05 06:04

Java\'s default encoding is ASCII. Yes? (See my edit below)

When a textfile is encoded in UTF-8? How does a Reader know that he has to use

5条回答
  •  失恋的感觉
    2020-12-05 06:19

    You can start getting the idea here java Charset API

    Note that according to the doc,

    The native character encoding of the Java programming language is UTF-16

    EDIT :

    sorry I got called away before I could finish this, maybe I shouldn't have posted the partial answer as it was. Anyway, the other answers explain the details, the point being that the native file charset for each platform together with common alternate charsets will be read correctly by java.

提交回复
热议问题