字符转码
来源:互联网 发布:mysql密码字典 编辑:程序博客网 时间:2024/06/06 00:00
import java.io.*;class CharCode{public static void main(String []args) throws Exception{//System.getProperty("file.encoding","iso8859-1");//System.getProperties().list(System.out);String strChina="中国";for(int i=0;i<strChina.length();i++){System.out.println(Integer.toHexString(strChina.charAt(i)));}byte [] buf=strChina.getBytes("gb2312");//byte [] buf=strChina.getBytes();//缺省和上面一样。for(int i=0;i<buf.length;i++){System.out.println(Integer.toHexString(buf[i]));}for(int i=0;i<buf.length;i++){System.out.write(buf[i]);}System.out.println();//自动调用flush,刷新缓冲区。//System.out.write(buf,0,4);System.out.println("中国");}}
import java.io.*;class CharDecode{//Ctrl+C 结束程序public static void main(String []args) throws Exception{System.out.println("Please enter a chinese String:");byte [] buf=new byte[1024];String strInfo=null;int pos=0;int ch=0;while(true){ch=System.in.read();System.out.println(Integer.toHexString(ch));switch(ch){case '\r':break;case '\n':strInfo=new String(buf,0,pos,"gb2312");//按GB2312编码转换成字符串//strInfo=new String(buf,0,pos);//缺省也是GB2312编码。for(int i=0;i<strInfo.length();i++){System.out.println(Integer.toHexString(/*(int)*/strInfo.charAt(i)));//字符串中的每一个字符的Unicode码}break;default:buf[pos++]=(byte)ch;}}}}
import java.io.*;class CharDecode{//Ctrl+C 结束程序public static void main(String []args) throws Exception{System.getProperties().put("file.encoding","iso-8859-1");System.out.println("Please enter a chinese String:");byte [] buf=new byte[1024];String strInfo=null;int pos=0;int ch=0;while(true){ch=System.in.read();System.out.println(Integer.toHexString(ch));switch(ch){case '\r':break;case '\n'://strInfo=new String(buf,0,pos,"gb2312");//按GB2312编码转换成字符串strInfo=new String(buf,0,pos);//缺省也是GB2312编码。被第一句改变成iso-8859-1。for(int i=0;i<strInfo.length();i++){System.out.println(Integer.toHexString((int)strInfo.charAt(i)));//字符串中的每一个字符的Unicode码}System.out.println(new String(strInfo.getBytes("iso-8859-1"),"gb2312"));break;default:buf[pos++]=(byte)ch;}}}}
- 字符转ASCII码
- 字符转码
- HTML字符转码
- 字符转码
- base64字符转码
- ruby字符转码
- 字符转码
- java字符转码
- 字符转码过滤器
- 字符转码过滤器
- php字符转码
- ascii码转字符
- HTML字符转码
- Java字符转码
- Java字符转码
- C++字符转码
- Java-字符转码
- java字符转码
- 项目中常见的SQL处理总结【二】
- Bloomberg 面试题05012012[1]
- 翻译:Linux的电源管理架构
- metro开发资料整理~
- 让Android adb运行在ARM平台上
- 字符转码
- fedora16无线网卡安装
- 你若安好,便是晴天
- 如何在Ubuntu11.10(32位)下载Android4.0源码(图文)
- 装机——跳线
- iPhone游戏编程- 启动画面
- Silverlight.XNA(C#)跨平台3D游戏研发手记:(八)向Windows Phone移植之2D跨平台迁移
- PowerDesigner 12小技巧
- 关于IE8无法上传附件的解决办法