本文介绍了如何转换特殊字符为十六进制? (Android中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I tried below method but it works only for ";", "#" etc
解决方案
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
这篇关于如何转换特殊字符为十六进制? (Android中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!