• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

platform's default character encoding

 
Alik Elzin
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
How can I get the platform's default character encoding ?
 
Philip Shanks
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Sun's Java site:
You can query an InputStreamReader or OutputStreamWriter (these are the classes that "bridge" byte streams to character streams), for its character encoding.
For example:

Now you have a String representation of the encoding.
This example would work in an applet too:

PCS
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alik,
Please change your name to be compliant with JavaRanch's naming policy.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
You can change your name: here.
Thanks,
Cindy
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On many systems, it's possible to get the default encoding thus:
System.getProperty("file.encoding")
However this is not guaranteed to work on all systems. The simplest way I know that is guaranteed is
new OutputStreamWriter(System.out).getEncoding()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic