Reputation: 2165
Convert some special characters into hex value.
For example :
Hex value of "ㅂ" is "e3 85 82"
Hex value of "ㅈ", "ㄷ", and "ㄱ" are "e3 85 88", "e3 84 b7", and "e3 84 b1" respectively.
I tried below method but it works only for ";", "#" etc
Integer.toHexString("ㅂ") , gives "3142" value. But correct hex value should be "e3 85 82".
Upvotes: 0
Views: 2152
Reputation: 1342
Your answer encoding is in UNICODE(hex) and you need to convert it into UTF8(hex)
Convert String to hex.
public static void main(String[] args) throws UnsupportedEncodingException {
String chr = "ㅂ";
System.out.print(toHex(chr));
}
//String to hex
public static String toHex(String arg) throws UnsupportedEncodingException {
//Change encoding according to your need
return String.format("%04x", new BigInteger(1, arg.getBytes("UTF8")));
}
Output:- e38582
Upvotes: 1