文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>java培训日记-1

java培训日记-1

时间:2007-10-06  来源:mecury1213

           传智播客北京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);

%>

www.itcast.cn

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载