Advertisement
Guest User

Untitled

a guest
Jun 17th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import java.io.UnsupportedEncodingException;
  2.  
  3. public class Test {
  4.  
  5. public static void main(String[] args) throws UnsupportedEncodingException {
  6. byte[] bytes = new byte[]{(byte) 240, (byte) 159, (byte) 146, (byte) 138};
  7. String str = new String(bytes, "UTF-8");
  8. System.out.println(str.length());
  9. for (int i = 0; i < str.length(); i++)
  10. System.out.println(Integer.toHexString(str.codePointAt(i)));
  11.  
  12. System.out.println();
  13.  
  14. char[] chars = Character.toChars(0x1f48a);
  15. System.out.println(chars.length);
  16. for (int i = 0; i < chars.length; i++)
  17. System.out.println(Integer.toHexString(chars[i]));
  18. }
  19. }
  20.  
  21. /*
  22. Output:
  23. 2
  24. 1f48a
  25. dc8a
  26.  
  27. 2
  28. d83d
  29. dc8a
  30. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement