开发者

what is the byte length for different character set in java?

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 开发者_如何转开发:)


Call Charset.availableCharsets().values();, iterate over the list and print some predefined string into ByteArrayOutputStream. Then get bytes and see the array length.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜