I thought Java determines 'file.encoding' system property by system locale.
But in my system while system locale is 'ko_kr.UTF-8', 'file.encoding' is 'ANSI_X3.4-1968'.
How does Java determine 'file.encoding' system property?
The native character encoding of the Java programming language is UTF-16. A charset in the Java platform therefore defines a mapping between sequences of sixteen-bit UTF-16 code units (that is, sequences of chars) and sequences of bytes.
Files generally indicate their encoding with a file header. There are many examples here. However, even reading the header you can never be sure what encoding a file is really using. For example, a file with the first three bytes 0xEF,0xBB,0xBF is probably a UTF-8 encoded file.
Java supports a wide array of encodings and their conversions to each other. The class Charset defines a set of standard encodings which every implementation of Java platform is mandated to support. This includes US-ASCII, ISO-8859-1, UTF-8, and UTF-16 to name a few.
Native code populating properties from the below link(for solaris,Linux operating system )
Below native method loading system properties.
private static native Properties initProperties(Properties props);
Below link is the native code link for loading properties( after line number 187)
Source for setting java properties
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With