/**
* 替换四个字节的字符 '\xF0\x9F\x98\x84\xF0\x9F)的解决方案 😁
* @author ChenGuiYong
* @data 2015年8月11日 上午10:31:50
* @param content
* @return
*/
public static String removeFourChar(String content) {
byte[] conbyte = content.getBytes();
for (int i = 0; i < conbyte.length; i++) {
if ((conbyte[i] & 0xF8) == 0xF0) {
for (int j = 0; j < 4; j++) {
conbyte[i+j]=0x30;
}
i += 3;
}
}
content = new String(conbyte);
return content.replaceAll("0000", "");
}
结果:
String title = "ff的范德萨分😁😁😁😁Llfldakf;dsk。f😁😁😁😁😁😁daslfjdsa;lfkjdsd'j'l'f'k'd'j'sa'l'k";
System.out.println(Test_Common2.removeFourChar(title).replaceAll("0000", ""));
//ff的范德萨分Llfldakf;dsk。fdaslfjdsa;lfkjdsd'j'l'f'k'd'j'sa'l'k
java 替换四个字节的字符 '-xF0-x9F-x98-x84-xF0-x9F)的解决方案 😁
点赞
收藏