Java examples for java.lang:String UTF
utf To Unicode
//package com.java2s; import java.lang.Character.UnicodeBlock; public class Main { public static String utf8ToUnicode(String inStr) { char[] myBuffer = inStr.toCharArray(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < inStr.length(); i++) { UnicodeBlock ub = UnicodeBlock.of(myBuffer[i]); if (ub == UnicodeBlock.BASIC_LATIN) { //???????? sb.append(myBuffer[i]);/*from ww w . j av a 2 s . c om*/ } else if (ub == UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) { //???????? int j = (int) myBuffer[i] - 65248; sb.append((char) j); } else { //?? short s = (short) myBuffer[i]; String hexS = Integer.toHexString(s); String unicode = "\\u" + hexS; sb.append(unicode.toLowerCase()); } } return sb.toString(); } }