如何十六进制值,以特殊字符转换(在统一$ C $三)? [英] How to convert hex value to Special Char( in Unicode )?

查看:386
本文介绍了如何十六进制值,以特殊字符转换(在统一$ C $三)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的<一个href=\"http://stackoverflow.com/questions/25120784/how-to-convert-special-characters-to-hex-in-android\">$p$pvious问题,我问了一下特殊字符转换为十六进制。


  

的十六进制值e38582


现在我已经得到的字符串中的十六进制值。


  

十六进制字符串=e38582;


  
  

如何将这个十六进制值转换,以获得特殊字符。(在这个例子中的


我试过这个,但得到IllegalFormatConversionException:

 字符串十六进制=e38582;
BigInteger值=新的BigInteger(十六进制,16);
字符串str =的String.format(%C,值);
的System.out.println(字符串:+ STR);


解决方案

  1. 将转换为十六进制字节数组。 <一href=\"http://stackoverflow.com/questions/140131/convert-a-string-re$p$psentation-of-a-hex-dump-to-a-byte-array-using-java\">Convert十六进制转储中使用Java字符串重新presentation字节数组?


  2. (根据你的previous问题,UTF-8)国际preT字节数组与正确的编码:

     字符串输出=新的字符串(字节,UTF-8);


In my previous question, I asked about conversion of Special Chars to Hex.

Hex value of "ㅂ" is "e38582"

Now I've got hex value in String.

String hex = "e38582";

How to convert this hex value to get the special char.( In this example it's "ㅂ" )

I've tried this, but getting IllegalFormatConversionException :

String hex = "e38582";
BigInteger value = new BigInteger(hex, 16);
String str = String.format("%c", value );
System.out.println("String : "+ str);

解决方案

  1. Convert the hex to byte array. Convert a string representation of a hex dump to a byte array using Java?

  2. Interpret the byte array with the correct encoding (based on your previous question, UTF-8):

    String output = new String(bytes, "UTF-8");
    

这篇关于如何十六进制值,以特殊字符转换(在统一$ C $三)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆