我在使用InputStreamReader接受中文的时候,中文的输入码也被接受了,但我想只要中文就行了
代码如下:
import java.io.*;
public class InputReader
{
public static void main(String[] args)throws Exception
{
InputStreamReader isr=new InputStreamReader(System.in,"iso8859-1");
BufferedReader br=new BufferedReader(isr);
String strLine=br.readLine();
for(int i=0;i<strLine.length();i++)
{
System.out.println(Integer.toHexString((int)strLine.charAt(i)));
}
isr.close();
System.out.println(strLine);
System.out.println(new String(strLine.getBytes("iso8859-1"),"gbk"));
}}
代码如下:
import java.io.*;
public class InputReader
{
public static void main(String[] args)throws Exception
{
InputStreamReader isr=new InputStreamReader(System.in,"iso8859-1");
BufferedReader br=new BufferedReader(isr);
String strLine=br.readLine();
for(int i=0;i<strLine.length();i++)
{
System.out.println(Integer.toHexString((int)strLine.charAt(i)));
}
isr.close();
System.out.println(strLine);
System.out.println(new String(strLine.getBytes("iso8859-1"),"gbk"));
}}
中国
6b
68
6c
67
d6
d0
b9
fa
khlg???ú
khlg中国
我用五笔输入的"中国",但它把五笔码也接收了,这个我不想要,用拼音也一样.这是怎么回事,怎么解决
import java.io.*;
public class InputReader
{
public static void main(String[] args)throws Exception
{
InputStreamReader isr=new InputStreamReader(System.in,"iso8859-1");
BufferedReader br=new BufferedReader(isr);
String strLine=br.readLine();
//for(int i=0;i <strLine.length();i++)
//{
//System.out.println(Integer.toHexString((int)strLine.charAt(i)));
//}
//isr.close(); //System.out.println(strLine);
System.out.println(new String(strLine.getBytes("iso8859-1"),"gbk"));
}
} 运行结果:
中国
中国
import java.io.*;
public class InputReader
{
public static void main(String[] args)throws Exception
{
InputStreamReader isr=new InputStreamReader(System.in,"iso8859-1");
BufferedReader br=new BufferedReader(isr);
String strLine=br.readLine();
for(int i=0;i <strLine.length();i++)
{
System.out.println(Integer.toHexString((int)strLine.charAt(i)));
}
isr.close(); //System.out.println(strLine);
System.out.println(new String(strLine.getBytes("iso8859-1"),"gbk"));
}
}
运行结果:
中国
d6
d0
b9
fa
中国
为何不用GBK编码呢?
中国
6b
68
6c
67
d6
d0
b9
fa
khlg中国
拼音:
中国
d6
d0
b9
fa
中国
拼音不打全,按数字键选择词组
中国
7a
68
6f
6e
67
67
d6
d0
b9
fa
zhongg中国
还是那个问题,我只想要中国,不要前边的字母,怎么解决