encodetester.java

来自「这一些程序都是实验之用」· Java 代码 · 共 30 行

JAVA
30
字号
import java.io.*;
public class EncodeTester{
	private static void readBuff(byte []buff)throws IOException{
		ByteArrayInputStream in=new ByteArrayInputStream(buff);
		int data;
		while((data=in.read())!=-1)
			System.out.print(data+" ");
			System.out.println();
			
			in.close();
}

public static void main(String args[])throws IOException{
	System.out.println("在内存中采用unicode字符编码");
	 char c='好';
	 int lowBit=c&0xff;
	 int highBit=(c&0xff00)>>8;
	 System.out.println(highBit+" "+lowBit);
	 
	 String s="好";
	 System.out.println("采用本地操作系统的默认字符编码");
	 readBuff(s.getBytes());
	 
	 System.out.println("采用GBK字符编码");
	 readBuff(s.getBytes("GBK"));
	 
	 System.out.println("采用标准UTF-8字符编码");
	 readBuff(s.getBytes("UTF-8"));
	 }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?