In doing a global search, encountered in the content of mobile phone expression, stored in the database is an error. Online search for a long time, found that many people do not go to experiment to copy other people's Code online hair, and then led me to use direct not. Finally found a way to do, summed up in this:
There are two main methods:
First, modify the database character set:
This method requires the hard requirements of your MySQL database version 5.5 later. Generally have database management tools, directly opened the change is, for example, I used the heidisql, directly to the table to UTF8MB4 on it. This approach is simple and easy, but you may need to restart the database. Another problem is that sometimes this method is not very good, the first time I used this method to solve the problem perfectly, but the second time, said nothing. Therefore, this way is still not recommended.
Second, filter out these expressions.
Now that the database can't be saved, just filter these expressions off. This situation is a way to make the service more convenient by damaging the customer's personality. At present many websites are doing so, after all efficiency is the key, you this expression even if save, also perhaps where again use, show not.
It is suggested that the tool method is convenient, practical and feasible.
/**
* Emoji expression Replacement
* *
@param Source Original String
* @param slipstr emoji expression replaced by the string
* @return Filtered String *
* Public
static String Filteremoji (String
source,string slipstr) {
if (Stringutils.isnotblank (source)) { return
Source.replaceall ("[\\ud800\\udc00-\\udbff\\udfff\\ud800-\\udfff]", slipstr);
} else{return
source;
}
Original: http://www.3fwork.com/b200/004985MYM000642/