Size of char in Java is two bytes. How can I get raw bytes from a char variable?
var ch = '文';
var b1 = // ?
var b2 = // ?
>Solution :
You can perform bitwise arithmetic on char to access the individual bytes:
var b1 = (byte) ch;
var b2 = (byte) (ch >> 8);
System.out.printf("%02x %02x\n", b1, b2);
// 87 65