技术

\xe6\x96\x87\xe6\x9e\x97\xe8

出现了标题那样的是因为中文或表情符转成了16进制,所以我们需要[将utf8 十六进制编码转换成汉字]


private String convertUTF8ToString(String account) {
  //\xe6\x96\x87-->%e6%96%87
  int index = account.indexOf("\\");
  String chiStr = "";
  if (index > -1) {
    account = account.replace("\\x", "%");
    try {
    	chiStr = URLDecoder.decode(account, "utf-8");
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
      chiStr = account;
    }
  } else {
  	chiStr = account;
  }
  return chiStr;
}

java代码过滤


public static String filterEmoji(String source) {  
        if (source != null && source.length() > 0) {  
            return source.replaceAll("[\ud800\udc00-\udbff\udfff\ud800-\udfff]", "");  
        } else {  
            return source;  
        }  
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注