我的java培训日记-1

 
传智播客 北京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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值