java獲取中文拼音首字母工具類

2021-08-31 15:42:28 字數 726 閱讀 9828

package com.sw.documentary.common.utils;

public class gb2alpha ;

private char alphatable =

;private int table = new int[27];

//初始化

}public gb2alpha()

//主函式,輸入字元,得到他的聲母,

//英文本母返回對應的大寫字母

//其他非簡體漢字返回 '0'

public char char2alpha(char ch)

if (i >= 26)

return '0';

else

return alphatable[i];

}//根據乙個包含漢字的字串返回乙個漢字拼音首字母的字串

public string string2alpha(string sourcestr)

} catch (exception e)

return result;

}private boolean match(int i, int gb)

//取出漢字的編碼

private int gbvalue(char ch) catch (exception e)

}public static void main(string args)

}

java獲取漢字拼音首字母

在專案中要更能根據某些查詢條件 比如姓名 的首字母作為條件進行查詢,比如查乙個叫 李曉明 的人,可以輸入 lxm 寫了乙個工具類如下 取得給定漢字串的首字母串,即聲母串 title chinesechartoen date 2004 02 19 注 只支援gb2312字符集中的漢字 public f...

js 根據中文獲取拼音首字母

js部分 var pinyin param str 判斷中英文 returns 中文返回true,其他返回false function ischinese str param str 獲取拼音的字串 param split 拼音分隔符 param uppercase 是否轉為大寫 returns 結...

js 獲取中文的拼音首字母

es6 模組化封裝 use strict module.exports 處理arrresult,返回所有可能的拼音首字母串陣列 return this mkrslt arrresult checkch ch 檢查是否是多音字,是按多音字處理,不是就直接在strchinesefirstpy字串中找對應...