jsp_页面中文乱码测试

本文来自http://www.blogjava.net/zhyiwww/archive/2009/02/04/253193.html

我喜欢原文中的代码

<%
    out.println("1 - "+new String("中文".getBytes())+"<br>");

    out.println("2 - "+new String("中文".getBytes(),"GB2312")+"<br>");
    out.println("3 - "+new String("中文".getBytes(),"ISO8859_1")+"<br>");
    out.println("4 - "+new String("中文".getBytes(),"UTF-8")+"<br>");
    out.println("5 - "+new String("中文".getBytes(),"GBK")+"<br>");
    
    out.println("11 - "+new String("中文".getBytes("UTF-8"), "UTF-8")+"<br>");
    out.println("12 - "+new String("中文".getBytes("UTF-8"), "GB2312")+"<br>");
    out.println("13 - "+new String("中文".getBytes("UTF-8"), "ISO8859_1")+"<br>");
    out.println("14 - "+new String("中文".getBytes("UTF-8"), "GBK")+"<br>");
    
    out.println("21 - "+new String("中文".getBytes("GBK"), "GBK")+"<br>");
    out.println("22 - "+new String("中文".getBytes("GBK"), "UTF-8")+"<br>");
    out.println("23 - "+new String("中文".getBytes("GBK"), "GB2312")+"<br>");
    out.println("24 - "+new String("中文".getBytes("GBK"), "ISO8859_1")+"<br>");
    
    out.println("31 - "+new String("中文".getBytes("GB2312"), "GB2312")+"<br>");
    out.println("32 - "+new String("中文".getBytes("GB2312"), "UTF-8")+"<br>");
    out.println("33 - "+new String("中文".getBytes("GB2312"), "GBK")+"<br>");
    out.println("34 - "+new String("中文".getBytes("GB2312"), "ISO8859_1")+"<br>");
    
    out.println("41 - "+new String("中文".getBytes("ISO8859_1"), "ISO8859_1")+"<br>");
    out.println("42 - "+new String("中文".getBytes("ISO8859_1"), "UTF-8")+"<br>");
    out.println("43 - "+new String("中文".getBytes("ISO8859_1"), "GB2312")+"<br>");
    out.println("44 - "+new String("中文".getBytes("ISO8859_1"), "GBK")+"<br>");
   %>

 这段代码虽然还是没有解决http://countme.iteye.com/blog/1125575 中的问题,可对我有很大的帮助,感谢原创的思想。

你可能感兴趣的:(中文乱码)