JAVA编码--Gbk-->Utf8
来源:互联网 发布:unity3d中UI text是 编辑:程序博客网 时间:2024/05/01 11:09
public static byte[] gbk2utf8(String chenese){
char c[] = chenese.toCharArray();
byte [] fullByte =new byte[3*c.length];
for(int i=0; i<c.length; i++){
int m = (int)c[i];
String word = Integer.toBinaryString(m);
// System.out.println(word);
StringBuffer sb = new StringBuffer();
int len = 16 - word.length();
//补零
for(int j=0; j<len; j++){
sb.append("0");
}
sb.append(word);
sb.insert(0, "1110");
sb.insert(8, "10");
sb.insert(16, "10");
// System.out.println(sb.toString());
String s1 = sb.substring(0, 8);
String s2 = sb.substring(8, 16);
String s3 = sb.substring(16);
byte b0 = Integer.valueOf(s1, 2).byteValue();
byte b1 = Integer.valueOf(s2, 2).byteValue();
byte b2 = Integer.valueOf(s3, 2).byteValue();
byte[] bf = new byte[3];
bf[0] = b0;
fullByte[i*3] = bf[0];
bf[1] = b1;
fullByte[i*3+1] = bf[1];
bf[2] = b2;
fullByte[i*3+2] = bf[2];
}
return fullByte;
}
- JAVA编码--Gbk-->Utf8
- java中GBK编码格式转成UTF8
- java中GBK编码格式转成UTF8
- GBK UTF8 编码转换
- 编码:utf8, unicode, GBK
- Java中的字符编码与解码 utf8 utf16 gbk
- GBK和UTF8编码处理
- 数据库编码转换 GBK------>UTF8。
- UTF8和GBK编码转换
- 编码ascii,latin1,utf8,gbk
- UTF8 和GBK编码转换
- lua utf8 gbk 编码转换
- java gbk utf8转换
- java gbk转utf8
- PHP中GBK和UTF8编码处理
- PHP中GBK和UTF8编码处理
- PHP中GBK和UTF8编码处理
- PHP中GBK和UTF8编码处理
- sturts分页处理
- Linux推荐网站
- XML DOm方法备忘录
- 设置文字样式并写入CAD
- fso支持的打开及关闭命令
- JAVA编码--Gbk-->Utf8
- XML DOm属性备忘录
- 建立CADUIPALETTE
- 程序开发EQ浅淡
- ab的博客,关注中石化
- 一个SQL Server数据库备份与还原操作的类
- 点光源,法线贴图+点光源,视差贴图+法线贴图+点光源的效果比较
- 5月了,新的生活又开始了
- switch语句