|
|
@@ -33,10 +33,32 @@ public class PinyinUtil {
|
|
|
* 中文汉字
|
|
|
* @return
|
|
|
*/
|
|
|
+// public static String getPinyin(String chinese) {
|
|
|
+// return getPinyinZh_CN(convertStringByChinese(chinese));
|
|
|
+// }
|
|
|
public static String getPinyin(String chinese) {
|
|
|
- return getPinyinZh_CN(convertStringByChinese(chinese));
|
|
|
+ try {
|
|
|
+ if (chinese == null) {
|
|
|
+ return "default";
|
|
|
+ }
|
|
|
+
|
|
|
+ String clean = chinese.replaceAll("\\s+", "");
|
|
|
+ if (clean.isEmpty()) {
|
|
|
+ return "default";
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<String> set = convertStringByChinese(clean);
|
|
|
+ if (set == null || set.isEmpty()) {
|
|
|
+ return "default";
|
|
|
+ }
|
|
|
+
|
|
|
+ return String.join(",", set);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return "default";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 拼音大写输出
|
|
|
*
|