关闭

我的java培训日记-1

138人阅读 评论(0) 收藏 举报
 
传智播客北京java培训日记-1
 
  
1. 字符编码的讲解
SCII与Unicode码的转换规则,演示记事本显示字符时的趣味问题,分析乱码原因,GB2312中也包含英文字符,如何识别GB2312中的英文与汉字。最后课结束时讲了GB18030
2. xml文档的作用举例
<world>                                                                                                               }
<country>
</country>
<country>
       <name>中国</name>
       <chairman></chairman>
       <provinces>
              <province>
                     <name>湖北</name>
                     <chairman></chairman>
                     <cities>
                            <city>
                     </cities>
              </province>
              <province>
                     <name>湖南</name>
              </province>
              <province>
                     <name>北京</name>
              </province>
       </provinces>
</country>
</world>
分析该内部原理:
World类{
//这里引出了对泛型的讲解                                                                        ArraList<Country> countrys = new ArrayList<Country>;
       //为什么world元素下面要加countries元素                                                             countrys.add(new Country())
}
3. 编码转换程序
              char [] codes = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
              byte b = (byte)Integer.parseInt(args[0]);
              System.out.print(codes[((b>>4) & 0x0f)]);
              System.out.println(codes[(b & 0x0f)]);      
得到字符的big5
<%@page pageEncoding="GBK"%>
<%@page contentType="text/html;charset=GBK"%>//修改contentType="audio/x-mp3"说明头的作用
<%
       String china="中一二";
       for(int i=0;i<china.length();i++)
       {
              out.println(Integer.toHexString((int)china.charAt(i)));
       }
       System.out.println();
       byte[] bufGBK = china.getBytes("GBK");
       for(int i=0;i<bufGBK.length;i++)
       {
              out.println(Integer.toHexString(bufGBK [i]));
       }
       byte[] buf = china.getBytes("Big5");
       for(int i=0;i<buf.length;i++)
       {
              out.println(Integer.toHexString(buf[i]));
       }
       byte [] buf ={0xa4, 0xa4,0xa4,0x40,0xa4,0x47}
%>
输出big5给浏览器:
<%
       byte [] buf ={(byte)0xa4, (byte)0xa4,(byte)0xa4,(byte)0x40,(byte)0xa4,(byte)0x47};
       response.getOutputStream().write(buf);
%>
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:980次
    • 积分:65
    • 等级:
    • 排名:千里之外
    • 原创:4篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档