注册
|
提交需求
|
订阅
|
English
首 页
解决方案
产 品
服 务
支 持
EDN系统
成功案例
关于我们
联系我们
树结构图
EDN系统
图形图像
网络安全
项目专题
WEB开发
办公系列
操作系统
数据库
程序设计
TOP 10
在Foxmail中如何使…
Ftp 子命令
BigDecimal
MSN在线客服功能模块使…
会员卡使用方法说明
DataInputStr…
留言板功能说明
CScript
BufferedInpu…
设置打印机
您现在的位置:
>
技术沙龙
>
WEB开发
>
JSP
>
jsp中任意文字转Unicode的通用模块
相关软件
>
jsp中任意文字转Unicode的通用模块
创建者:
webmaster
更新时间:
2005-05-18
13:20
/** 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 < strText.length(); 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 */
<% String lang = "这是简体中文"; %>
<%=lang %>
<%=g2u.toUnicode(lang,"GBK") %>
相关文章
前一则:
jsp文件操作之追加篇
后一则:
Java Servlet/Jsp多语言解决方案
本页查看次数:
公司公告
|
客户调查
|
法律声明
|
诚聘英才
|
给我们投稿
|
繁
闪
头像
京ICP备05031245号
Copyright @ REDCOME.com ALL Rights Reserved
北京怡康软件科技有限公司 地址:北京市昌平区东小口立汤路188号北方明珠大厦1号楼2708 邮编:102218 电话:84909966 传真:84909900 QQ:335601661