How do we know which charset the OS is using? For example, I know that Japanese Windows 95 encoding is MS932, but how do we know which charset it uses?

Mark Thornton

There is an undocumented system property ("file.encoding" I think) which gives the name of the default encoding. A better way is to create an OutputStreamWriter without specifiying the encoding and then use the getEncoding method to determine the name of the encoding actually used.

The bad news is that both these methods give the encoding used by Windows api and not the encoding used by a command window. Usually these two character sets are different (you can change this, at least on Windows NT). There is no way in Java to determine the codepage being used by the current command window (if any) unless you use JNI. For example, on my system the Windows codepage is 1252, while the default command window code page is 850.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact