当前位置: 技术问答>java相关
如何得到一个字符的unicode码?
来源: 互联网 发布时间:2015-06-10
本文导语: 高手帮忙! | 分分太少,不过还是帮帮你吧。 /** * 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 unicod...
高手帮忙!
|
分分太少,不过还是帮帮你吧。
/**
* 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