|
@@ -5,6 +5,7 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
|
|
|
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
|
|
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
|
|
|
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
/**
|
|
|
* 拼音和五笔编码工具
|
|
@@ -66,6 +67,9 @@ public class PyWbUtil {
|
|
|
* @return
|
|
|
*/
|
|
|
public static String toBigFirstChar(String chines) {
|
|
|
+ if(StringUtils.isNotBlank(chines)&& chines.length()>8){
|
|
|
+ chines = chines.substring(0,8);
|
|
|
+ }
|
|
|
String pinyinName = "";
|
|
|
char[] nameChar = chines.toCharArray();
|
|
|
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
|
|
@@ -93,6 +97,10 @@ public class PyWbUtil {
|
|
|
* @return
|
|
|
*/
|
|
|
public static String getWBCode(String str) {
|
|
|
+ if(StringUtils.isNotBlank(str)&& str.length()>8){
|
|
|
+ str = str.substring(0,8);
|
|
|
+ str=str.replaceAll("(","(").replaceAll(")",")");
|
|
|
+ }
|
|
|
StringBuffer result = new StringBuffer();
|
|
|
//用char循环取得每一个String的 字符
|
|
|
for (int i = 0; i < str.length(); i++) {
|