*/utf-8 Chinese byte length: 6utf-16 Chinese byte length: 6utf-16be Chinese byte length: 4utf-16le Chinese byte length: 4utf-32 Chinese byte length: 8utf-32be Chinese byte length: 8utf-32le Chinese byte length: 8unicode Chinese byte length: 6GBK Chinese bytes Length: 4gb2312 Chinese byte length: 4gb18030 Chinese byte length: 4iso8859-1 Chinese byte length: 2big5 Chinese byte length: 3ASCII Chinese byte length: 2-------------------------------------- -----------*/package Com.jlsoft.demo;import Java.io.unsupportedencodingexception;public class Chinabytelength { Static String [] charset = {"Utf-8", "utf-16", "Utf-16be", "Utf-16le", "UTF-32", "Utf-32be", "Utf-32le", "Unicode", "GBK", " GB2312 "," GB18030 "," iso8859-1 "," BIG5 "," ASCII "};p ublic static void ByteLength (String charset,string Test) throws unsupportedencodingexception {System.out.println (charset+ "Chinese byte Length:" +test.getbytes (CharSet). length);} public static void Main (string[] args) throws unsupportedencodingexception {for (int i = 0; i < charset.length; i++) {B Ytelength (Charset[i], "China");}}
Work encountered, so do a code summary, the most typical UTF-8 a Chinese character bytecode length is 3, while the GBK Chinese character bytecode length is 2, English is 1.
Characters in JAVA are different in different encodings