wood burning stoves 2.0*
The moose likes Java in General and the fly likes how can i get a String's encoding.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how can i get a String Watch "how can i get a String New topic
Author

how can i get a String's encoding..

Justin prim
Greenhorn

Joined: Apr 06, 2002
Posts: 2
I want to know how to get string encode.
thx.
John Dale
Ranch Hand

Joined: Feb 22, 2001
Posts: 399
Values of the String class or char type are represented in Unicode using 16-bit values. Are you asking how to determine the values of strings stored in other places, like files?
Justin prim
Greenhorn

Joined: Apr 06, 2002
Posts: 2
you Know that Constructor :
String(byte[] bytes, String charsetName)
Constructs a new String by decoding the specified array of bytes using the specified charset.
I want to know how can I get charsetName of String.
John Dale
Ranch Hand

Joined: Feb 22, 2001
Posts: 399
To get a list of encodings supported by a particular release of the Java runtime, see the Supported Encodings document for that release. For example, for Java 1.3, see http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html
This will give you a list of the possible charasetName values for the constructor. (Be sure to look at the link to the java.lang package document.)
To determine which one to use, you need to know which one was used to represent the characters as the byte array you want to process. For example, if you are working on a Windows machine in the US, and the characters came from a file encoded as one character per byte, your data is probably encoded as Cp1252. If you are on a Unix machine in the US, it is more likely to be ISO8859_1 (a subset of Cp1252, unless the Java translation tables do something unusual with characters 0x80-0x9F).
If you are on a Windows NT machine and data was read from a Unicode file, then the encoding would be UTF-16 if, as I recall, Windows uses a byte order mark for Unicode files.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how can i get a String's encoding..
 
Similar Threads
Book Promotion : Hacking Exposed: J2EE and Java
JavaRanch is the 258th biggest board on the web
Gmail Invites..any takers..?
Sticky topic
orkut