
我在网上的某个地方捡到了这个:
String unescape(String s) { int i=0, len=s.length(); char c; StringBuffer sb = new StringBuffer(len); while (i < len) { c = s.charAt(i++); if (c == '\') { if (i < len) { c = s.charAt(i++); if (c == 'u') { // TODO: check that 4 more chars exist and are all hex digits c = (char) Integer.parseInt(s.substring(i, i+4), 16); i += 4; } // add other cases here as desired... } } // fall through: escapes itself, quotes any character but u sb.append(c); } return sb.toString();}欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)