汉字与16进制、汉字与Html转义符的转换
package test;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
/**
* @category 功能1:汉字与16进制的转换<br/>功能2:汉字与Html转义符的转换
* @author 作者:李易烜<br/>邮箱:chinaliyixuan@hotmail.com
* @date 创建时间:Feb 24, 2010 4:35:23 PM
* @version 版本号:1.0
* @copyright 版权所有:GEOSOFT (Beijing) Co.Ltd.
*/
public class StringTest {
public static void main(String[] args) throws UnsupportedEncodingException {
String hex = URLEncoder.encode("李易烜", "UTF8");
String chsHex = URLDecoder.decode(hex, "utf8");
System.out.println("汉字到16进制 ==> " + hex);
System.out.println("16进制到汉字 ==> " + chsHex);
System.out.println();
//---------------------------------------------
String src = "李易烜";
String htmlStr = "";
String cnStr = "";
for(int i=0; i!=src.length(); i++){
int str = src.codePointAt(i);
htmlStr = htmlStr+"&#"+str+";";
cnStr = cnStr+""+(char)str;
}
System.out.println("汉字到html转义符 ==> " + htmlStr);
System.out.println("html转义符到汉字 ==> " + cnStr);
}
}
输出结果:
汉字到16进制 ==> %E6%9D%8E%E6%98%93%E7%83%9C
16进制到汉字 ==> 李易烜
汉字到html转义符 ==> 李易烜
html转义符到汉字 ==> 李易烜
相关文档:
Struts HTML标签
<html:html>标签
属性的作用:
lang: 值为true时,就根据存储在HttpSession中的Locale对象来输出网 页使用的语言。如果不存在session或session中没有Locale对象, 就以Http请求头中的Accept-language属性来设置输出语言。如果 &nbs ......
<html>
<head>
<title>实现字体阴影 </title>
</head>
<body>
<div STYLE="position:relative; width=480; &nb ......
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.StringReader;
import java.util.List;
import com.lowagie.text.Document;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.html.simpleparser.HTMLWorker;
import com.lowagie.te ......
Apache SSI技术可以动态的包含静态html文件 ,由于这个是apache直接进行处理,效率比一般的如jsp,php,asp等要强得多,因此被很多大访问量网站使用,下面讲述如何配置SSI
1)系统环境:
Apache 2.0.58
Red Hat Enterprise Linux AS release 4 (Nahant)
2)SSI使用的是mod_include的动态系统对象,一般默认的情况安装的情况 ......