Default Encoding and Changes

Default Characterand Stringuse UTF-16, but, for all practical purposes, in North America and most of the English UTF-8 locale is sufficient (as it can go up to 4 bytes). So, if I use InputStreamReader(InputStream), does this give me the default UTF-16 encoding char? Using InputStreamReader(InputStream, "UTF-8")would provide UTF-8 encoding, which would be sufficient for my purpose.

How can I automatically set the default JVM encoding to UTF-8 when using English? The goal is to improve performance for Characterboth Stringmanipulation (using an 8-bit scheme instead of 16-bit encoding, and most ASCII is covered using 8-bit encoding and at the same time conforms to the Unicode standard).

Any comments are welcome. Thanks!

+4
source share
2 answers

So, if I use InputStreamReader (InputStream), then this gives me the default UTF-16 char encoding? Using InputStreamReader (InputStream, "UTF-8") will provide UTF-8 encoding, which is sufficient for my purpose.

JVM UTF-8 ?

InputstreamReader java DOC:

, InputStreamReader, , .

reader.getEncoding(); UTF-8. Java , System.getProperty("file.encoding") JVM. , Java file.encoding, "UTF-8" . JVM System.setProperty("file.encoding, "UTF-16"").

.

+1

java, char, Character String - UTF-16. . . .

, , - , Java chars-on-the-inside. UTF-8 .

+4

All Articles