您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

jsp中任意文字转Unicode的通用模块_MySQL

2024/6/20 0:32:42发布19次查看
/** tounicode.java */
package com.edgewww.util;
import java.io.*;
/**
* 字符串转换成unicode码的类
* @author 栾金奎 jsp@shanghai.com
* @date 2001-03-05
*/
public class tounicode {
/**
* 把字符串转换成unicode码
* @param strtext 待转换的字符串
* @param code 转换前字符串的编码,如gbk
* @return 转换后的unicode码字符串
*/
public string tounicode(string strtext,string code) throws unsupportedencodingexception{
char c;
string strret = ;
int intasc;
string strhex;
strtext = new string(strtext.getbytes(8859_1),code);
for ( int i = 0; i c = strtext.charat(i);
intasc = (int)c;
if(intasc>128){
strhex = integer.tohexstring(intasc);
strret = strret + + strhex+;;
}
else{
strret = strret + c;
}
}
return strret ;
}
}
/** 应用举例 */
/** gbk2unicode.jsp */
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product