获取汉字首字母
来源:互联网 发布:银鼎天贵金属行情软件 编辑:程序博客网 时间:2024/06/11 20:52
不能解决汉语多音问题,“圳” 字不能正常转换,会显示为“ * ”
private void button1_Click(object sender, EventArgs e) { int len = textBox1.Text.Length;//输入汉字 string myStr = ""; for (int i = 0; i < len; i++) { myStr += getSpell(textBox1.Text.Substring(i, 1)); } textBox2.Text = myStr;//显示汉字首字母 }
private static string getSpell(string cnChar) { byte[] arrCN = Encoding.Default.GetBytes(cnChar); if (arrCN.Length > 1) { int area = (short)arrCN[0]; int pos = (short)arrCN[1]; int code = (area << 8) + pos; int[] areacode = { 45217, 45253, 45761, 46318, 46826, 47010, 47297, 47614, 48119, 48119, 49062, 49324, 49896, 50371, 50614, 50622, 50906, 51387, 51446, 52218, 52698, 52698, 52698, 52980, 53689, 54481 }; for (int i = 0; i < 26; i++) { int max = 55290; if (i != 25) max = areacode[i + 1]; if (areacode[i] <= code && code < max) { return Encoding.Default.GetString(new byte[] { (byte)(65 + i) }); } } return "*"; } else return cnChar; }
0 0
- 获取汉字首字母
- 获取汉字拼音首字母
- 获取汉字的首字母
- 获取汉字的首字母
- 获取汉字首字母
- 获取汉字的首字母
- 获取汉字拼音首字母
- 获取汉字首字母
- 获取汉字的首字母
- C#获取汉字首字母
- 获取汉字拼音首字母
- C#获取汉字首字母
- Java 获取汉字首字母
- C#获取汉字首字母
- 获取汉字拼音首字母
- 汉字获取首字母多音字
- python 获取汉字首字母
- C#获取汉字首字母
- LIS问题(转换成LCS解法 O(n*n))
- 15分钟 - Gas Station
- 水性杨花女人的特点
- 节点datanode无法启动
- 个人赛 J: 导弹拦截系统
- 获取汉字首字母
- hdu1394 Minimum Inversion Number
- 在ASP.NET中操作文件的例子(VB)
- 如何实现动态添加Html文档中Form项
- 用FSO获得图片文件的信息(大小,宽,高)
- ASP+Access的安全隐患及对策
- Implement EDKII internal command(一)
- ASP.NET中的ViewState
- asp.net生成缩略图