推荐于2016-03-31
展开全部
回答完毕,采纳即可。
package test;
public class YuGiOh
{
public static String convert ( String u8hex )
{
String[] array = u8hex.replaceAll ("(.{6})", "$1,").replaceAll ("\\,$", "").split ("\\,");
String result = "";
for ( int i = 0; i < array.length; i++ )
{
String u8bin = Integer.toBinaryString (Integer.parseInt (array[i], 16));
String bin = u8bin.substring (4, 8) + u8bin.substring (10, 14) + u8bin.substring (14, 16) + u8bin.substring (18, 20) + u8bin.substring (20, 24);
String code = Integer.toHexString (Integer.parseInt (bin, 2));
String nativeValue = "";
try
{
nativeValue += (char) Integer.parseInt (code.substring (0, 4), 16);
if (code.length () > 4)
{
nativeValue += code.substring (4, code.length ());
}
}
catch (NumberFormatException e)
{
result += code;
}
result += nativeValue;
}
return result;
}
public static void main ( String[] args )
{
String u8hex = "E4B88AE7BD91";
System.out.println (convert (u8hex));
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询