当前位置: 技术问答>java相关
请教:java转换成unicode的方法
来源: 互联网 发布时间:2015-07-14
本文导语: 小弟正在做的毕设要用到,急! | 16进制的unicode怎么样,共享: /** * filename:uI18n.java * @version 1.0 * @author yakuu */ package com.yakuu.forum.util; import java.io.*; import java.io.Serializable; //Convert double...
小弟正在做的毕设要用到,急!
|
16进制的unicode怎么样,共享:
/**
* filename:uI18n.java
* @version 1.0
* @author yakuu
*/
package com.yakuu.forum.util;
import java.io.*;
import java.io.Serializable;
//Convert double byte words to unicode. ignore the character and the number
public class uI18n implements java.io.Serializable {
public uI18n(){}
public static String toHEXString(byte b) {
return (""+"0123456789ABCDEF".charAt(0xf&b>>4)+"0123456789ABCDEF".charAt(b&0xF));
}
public static String getUnicode(String setStr) {
String szRet = "";
String szRetTmp = null;
String str = null;
try {
try {
str = new String(setStr.getBytes("ISO-8859-1"),"GBK");
}catch(Exception ex){
ex.printStackTrace();
}
byte[] bb = str.getBytes("UTF16");
for(int i = 2; i
/**
* filename:uI18n.java
* @version 1.0
* @author yakuu
*/
package com.yakuu.forum.util;
import java.io.*;
import java.io.Serializable;
//Convert double byte words to unicode. ignore the character and the number
public class uI18n implements java.io.Serializable {
public uI18n(){}
public static String toHEXString(byte b) {
return (""+"0123456789ABCDEF".charAt(0xf&b>>4)+"0123456789ABCDEF".charAt(b&0xF));
}
public static String getUnicode(String setStr) {
String szRet = "";
String szRetTmp = null;
String str = null;
try {
try {
str = new String(setStr.getBytes("ISO-8859-1"),"GBK");
}catch(Exception ex){
ex.printStackTrace();
}
byte[] bb = str.getBytes("UTF16");
for(int i = 2; i