!23 修正中文拼音首字母空数组判断

Merge pull request !23 from zhouinfo/master
This commit is contained in:
卓源软件
2022-02-15 07:14:11 +00:00
committed by Gitee

View File

@@ -52,7 +52,7 @@ public class PinyinUtils {
if (arr[i] > 128) {
try {
String[] temp = PinyinHelper.toHanyuPinyinStringArray(arr[i], Static.defaultFormat);
if (temp != null) {
if (temp != null && temp.length > 0) {
pybf.append(temp[0].charAt(0));
}else{
pybf.append(String.valueOf(arr[i]));
@@ -155,7 +155,7 @@ public class PinyinUtils {
}
// public static void main(String[] args) {
// String str = "你好123世界abc,~!#$_Sdf-";
// String str = "你好123🅻🅾🆅🅴、世界abc,~!#$_Sdf-";
// System.out.println(getFirstSpell(str));
// System.out.println(getFirstSpell(str, false));
// System.out.println(getFullSpell(str));