This commit is contained in:
2022-03-30 19:21:22 +08:00
parent 97cd46c8c2
commit 14c58bdba9
2 changed files with 14 additions and 7 deletions
@@ -25,6 +25,7 @@ import java.util.zip.GZIPOutputStream;
import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.dictionary.py.Pinyin;
import com.sun.javafx.scene.transform.TransformUtils;
import net.sf.json.JSON;
import net.sf.json.JSONArray;
import net.sf.json.JSONNull;
@@ -1827,18 +1828,23 @@ public class DataUtil {
public static boolean isChineseChar(String c) {
if (StringUtils.isNotBlank(c)) {
String temp = String.valueOf(c);
Pattern pattern = Pattern.compile("[\\u4e00-\\u9fa5]+");
Pattern pattern = Pattern.compile("[\\u4e00-\\u9fa5\\w]+");
Matcher matcher = pattern.matcher(temp);
return matcher.matches();
}
return false;
}
public static void main(String[] args) {
System.out.println(getFirstChar("文裕花园"));
System.out.println(getFirstChar("文怡花园"));
System.out.println(FourUpSixInto("258.393", 2));
public static void main(String[] args) {
System.out.println(isChineseChar("6文怡a花园"));
// System.out.println(getFirstChar("文怡花园"));
//
// System.out.println(FourUpSixInto("258.393", 2));
}
@@ -181,8 +181,9 @@ public class SaleLeadsController {
Method m = saleLeads.getClass().getMethod("get"+fildName);
String value = (String)m.invoke(saleLeads);
if(StringUtils.isNotBlank(value)){
if(!DataUtil.isChineseChar(value)){
String newValue = new String(value.getBytes("ISO8859-1"), "UTF-8");
String s1 = value.replaceAll("\\pP|\\pS", "");
if(!DataUtil.isChineseChar(s1)){
String newValue = new String(value.getBytes("ISO8859-1"), "UTF-8");
m = saleLeads.getClass().getMethod("set"+fildName,String.class);
m.invoke(saleLeads, newValue);
}