Java中char的字节数
摘要:
以前一直以为char占一个字节,后来发现远没这么简单。Java中char的字节数,和编码有关。使用UTF-8,英文字符占1个字节,中文占3个字节。下面在是在Ubuntu中测试的结果: public static void main(String[] args) throws IOException { String chnStr = "中文"; System.out.println("length of two Chinese character: " + chnStr.getBytes("UTF-8").length ); Stri 阅读全文
posted @ 2013-04-21 20:19 jubincn 阅读(1968) 评论(0) 推荐(0)
浙公网安备 33010602011771号