日期:2014-05-20  浏览次数:20734 次

小弟初学,求编码解码该题的菜鸟问题!!!
[code=Java][/code]
System.out.println("please enter a Chinese String");
byte [] buf=new byte[1024];
int ch=0;
int pos=0;
String strInfo=null;
while(true)
{  
ch =System.in.read();
System.out.println(Integer.toHexString(ch)); //问题1
switch(ch)
{
case '\r':
break;
case '\n':
strInfo= new String(buf,0,pos);
for(int i=0;i<strInfo.length();i++) //问题2
{
System.out.println(Integer.toHexString
((int)strInfo.charAt(i)));
}
System.out.println(strInfo);
for(int i=0;i<pos;i++)
System.out.write(buf[i]);
System.out.println();
return;
default:
buf[pos++]=(byte)ch;
}
请问:在这里我看不出怎么个解码,(将本地字符集转换成unicode),在别的地方问没结果,小弟初学者,对编码解码一直有点疑惑,望高手详解!!

------解决方案--------------------
你得代码貌似少IO,另外转码也不是用integer类,是用string下的一个方法
------解决方案--------------------
代码都不完整