fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. byte[] big5Bytes=new byte[]{ (byte)0xAB , (byte)0xA2 };
  14. byte[] utf8Bytes=new byte[]{ (byte)0xE5 , (byte)0x93 , (byte)0x88};
  15. String strBig5=new String(big5Bytes,"Big5");
  16. String strUTF8=new String(utf8Bytes,"UTF8");
  17.  
  18. System.out.println("-------- \"\" in Unicode encoding----------");
  19. byte[] unicodeBytes="哈".getBytes("Unicode");
  20. for(byte b:unicodeBytes) System.out.printf("%02X ",b);
  21. System.out.println("\n----------------------");
  22.  
  23.  
  24. System.out.println(" strBig5 = "+strBig5);
  25. System.out.println(" strUTF8 = "+strUTF8);
  26.  
  27. System.out.println("===== strBig5 store in Java =====");
  28. for(int i=0;i<strBig5.length();i++)
  29. System.out.printf("%04X ",strBig5.codePointAt(i));
  30. System.out.println();
  31. System.out.println("===== strUTF8 store in Java =====");
  32. for(int i=0;i<strUTF8.length();i++)
  33. System.out.printf("%04X ",strUTF8.codePointAt(i));
  34. }
  35. }
Success #stdin #stdout 0.1s 381696KB
stdin
Standard input is empty
stdout
-------- "哈" in Unicode encoding----------
FE FF 54 C8 
----------------------
 strBig5 = 哈
 strUTF8 = 哈
===== strBig5 store in Java =====
54C8 
===== strUTF8 store in Java =====
54C8