\u5E7F\u4E1C \u5E7F\u4E1C\u7701这是什么编码格式?
如题,在Java中如何将字符串转换成这种格式呢?
[解决办法]
java\bin下面有一个命令
Native2Ascii
查找用法,转码
[解决办法]
unicode
/** * 字符串转化为unicode * @param gbString * @return */ public static String encodeUnicode(final String gbString) { char[] utfBytes = gbString.toCharArray(); String unicodeBytes = ""; for (int byteIndex = 0; byteIndex < utfBytes.length; byteIndex++) { String hexB = Integer.toHexString(utfBytes[byteIndex]); if (hexB.length() <= 2) { hexB = "00" + hexB; } //unicodeBytes = unicodeBytes + "\\u" + hexB; unicodeBytes = unicodeBytes + hexB; } System.out.println(unicodeBytes); return unicodeBytes; } // unicode转化汉字 public static StringBuffer decodeUnicode(String utfStr) { final StringBuffer buffer = new StringBuffer(); String charStr = ""; String operStr = utfStr; for(int i =0 ; i < utfStr.length() ;i=+4){ charStr = operStr.substring(0, 4); operStr = operStr.substring(4, operStr.length()); char letter = (char) Integer.parseInt(charStr, 16); buffer.append(new Character(letter).toString()); } return buffer; }