/** * Replace the four-byte character ' \xf0\x9f\x98\x84\xf0\x9f ' solution?? * @author Chenguiyong * @data August 11, 2015 Morning 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", "" "); }
Results:
String title = "FF's van der Sar sub???????? Llfldakf;dsk. F???????????? DASLFJDSA;LFKJDSD ' J ' l ' F ' k ' d ' j ' sa ' l ' k '; System.out.println (Test_common2.removefourchar (title) replaceall ("0000", "" ")); The FF's Van der Sar points Llfldakf;dsk. FDASLFJDSA;LFKJDSD ' J ' l ' F ' k ' d ' j ' sa ' l ' k
Java replaces the four-byte character ' \xf0\x9f\x98\x84\xf0\x9f ' solution??