刚接触java,直接用了,没有系统地看书,有几个问题:String貌似是unicode的。我从GBK文件读取了n字节到 byte数组 buffer[]然后构造String(buffer, "GBK")得到 str_unicode现在我把str_unicode用getBytes()和toCharArray()得到byte数组和char数组分别是 byte_arr[] 和 char_arr[]现在我知道 str_unicode.length()是中文的字符数目,肯定小于 buffer.length ,没有异议。char_arr.length和str_unicode.length()一样,说明char也是unicode字符。然后byte_arr,和buffer.length不一样,比这个大。说明byte_arr其实是真正的字节数。问题:
str_unicode是unicode的存储,我知道他原来是从GBK转换过来的,现在我想知道,怎么样把str_unicode解压出GBK的byte流。谢谢。
str_unicode是unicode的存储,我知道他原来是从GBK转换过来的,现在我想知道,怎么样把str_unicode解压出GBK的byte流。谢谢。
http://blog.csdn.net/lky5387/archive/2008/10/09/3041993.aspx
byte[] bytes = str_unicode.getBytes( "GBK" );