|
![]() |
名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
** ToUnicode.java */ package com.edgewww.util; import java.io.*; /** * 字符串转变成Unicode码的类 */ 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 + "&#x" + strHex+";"; } else{ strRet = strRet + c; } } return strRet ; } } /** 应用举例 */ /** gbk2Unicode.jsp */ <meta http-equiv="Content-Type" content="text/html; charset=big5"> <jsp:useBean id="g2u" scope="session" class="com.edgewww.util.ToUnicode"/> <% String lang = "这是简体中文"; %> <br> <%=lang %> <br> <%=g2u.toUnicode(lang,"GBK") %> 返回类别: 教程 上一教程: TOMCAT的初学体验 下一教程: JSP+JAVABEAN循序渐进教程(五) 您可以阅读与"JSP中任意文字转UNICODE的通用模块"相关的教程: · 多中WEB服务器的通用JSp源代码暴露漏洞 · 穷人的通用OLAP方案III--JPivot表现层 · Allaire JRUN 2.3 查看任意文件漏洞 · SERVLET和JSP的通信的一种方式 · Apache泄露重写的任意文件漏洞 |
![]() ![]() |
快精灵印艺坊 版权所有 |
首页![]() ![]() ![]() ![]() ![]() ![]() ![]() |