在日常的程式設計中,我們可能會根據輸入的拼音或者漢字來獲取其對應包含該字元的的有效資訊,這時我們就會用到其對應的全拼或者簡拼。在資料量不是特別大時,還可以手動輸入,但是這樣會給使用者帶來不良的體驗,造成一定的繁瑣。所有在這些操作方面,我們都盡量使用程式來實現,下面就是乙個關於獲取文字的特殊類,如有更好的,還希望大家多多交流
//////獲得漢字的拼音
///static
public
class
pinyinhelper
#endregion
//////
獲得漢字的拼音,如果輸入的是英文本元將原樣輸出,中文標點符號將被忽略
/// ///
漢字字串
///拼音 static
public
string getpinyin(string
chinesechars)
else
}return
sb.tostring();
}//////
獲得漢字拼音的簡寫,即每乙個漢字的拼音的首字母組成的串,如果輸入的是英文本元將原樣輸出,中文標點符號將被忽略
/// ///
漢字字串
///拼音簡寫
static
public
string getshortpinyin(string
chinesechars)
}else
}return
sb.tostring();
}static
private
string getpinyin(int
charvalue)
}
根據輸入漢字獲取其全拼及簡拼
獲得漢字的拼音 static public class pinyinhelper endregion 獲得漢字的拼音,如果輸入的是英文本元將原樣輸出,中文標點符號將被忽略 漢字字串 拼音 return sb.tostring 獲得漢字拼音的簡寫,即每乙個漢字的拼音的首字母組成的串,如果輸入的是英文本...
輸入漢字獲取漢字的首字母和全拼
獲取漢字的首字母 public string indexcode string indextxt private string getoneindex string oneindextxt convert.toint16 gb2312bytes 0 160 string.format convert...
輸入漢字獲取漢字的首字母和全拼
獲取漢字的首字母 public string indexcode string indextxt private string getoneindex string oneindextxt convert.toint16 gb2312bytes 0 160 string.format convert...