Reputation: 12349
I want to know the different byte length of character set provided by JVM. For example, ASCII, non-acsii char set, chinese characters and so on.
Any idea thanks :)
Upvotes: 1
Views: 603
Reputation: 799180
ASCII, CP*, and ISO 8859-* are 1 byte. UCS-2 is 2 bytes. UTF-16 is 2 or 4 bytes. UTF-32 and UCS-4 are 4 bytes. Most others (UTF-8, GB2312, EUC-JP, ShiftJIS, etc.) are variable.
Upvotes: 0
Reputation: 115378
Call Charset.availableCharsets().values();
, iterate over the list and print some predefined string into ByteArrayOutputStream. Then get bytes and see the array length.
Upvotes: 1