Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.UnsupportedEncodingException;
- public class Test {
- public static void main(String[] args) throws UnsupportedEncodingException {
- byte[] bytes = new byte[]{(byte) 240, (byte) 159, (byte) 146, (byte) 138};
- String str = new String(bytes, "UTF-8");
- System.out.println(str.length());
- for (int i = 0; i < str.length(); i++)
- System.out.println(Integer.toHexString(str.codePointAt(i)));
- System.out.println();
- char[] chars = Character.toChars(0x1f48a);
- System.out.println(chars.length);
- for (int i = 0; i < chars.length; i++)
- System.out.println(Integer.toHexString(chars[i]));
- }
- }
- /*
- Output:
- 2
- 1f48a
- dc8a
- 2
- d83d
- dc8a
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement