c 中如何得到漢字的拼音首字母

2021-04-24 02:18:41 字數 873 閱讀 8031

新增命名空間

using system.text.regularexpressions;

///  

///   判斷是否為漢字  

///  

///   待檢測字串

///   是漢字返回true

public bool ischinesecharacters(string chrstr)

///

/// 得到每個漢字的字首拼音碼字母(大寫)

///

/// 輸入字串

/// 返回結果

public string getheadcharacter(string chrstr)

byte bytes = gb.getbytes(chrstr.substring(i, 1));

string lowcode = system.convert.tostring(bytes[0] - 0xa0, 16);

string hightcode = system.convert.tostring(bytes[1] - 0xa0, 16);

int ncode = convert.touint16(lowcode, 16) * 100 + convert.touint16(hightcode, 16);      //得到區位碼

strheadstring += firstletter(ncode);

}return strheadstring;

}///

/// 通過漢字區位碼得到其首字母(大寫)

///

/// 漢字編碼

///

public string firstletter(int ncode)

}

漢字轉拼音首字母

public string hz2py string hz 獲得漢字的區位碼 else if tmp 45253 tmp 45760 else if tmp 47761 tmp 46317 else if tmp 46318 tmp 46825 else if tmp 46826 tmp 47009...

獲取漢字拼音首字母

有個專案需要用到生成漢字的首字母,但從網上查了一下,對於多音字的處理都不是很好,所以就利用pinyin4j這個工具包自己寫了乙個。用到的jar包是pinyin4j 2.5.0.jar 獲取拼音首字母,多音字用逗號隔開 public static string getfirstspell string...

獲取漢字拼音首字母

unit py inte ce uses sysutils 獲取漢字的拼音首字元,這個函式將用在getpyindexstr 中.function getpyindexchar strchinese string bupcase boolean true char 獲取多個漢字的拼音首字元組成的字串....