C#中 利用汉字在计算机里面的编码来得到汉字的首拼音 及 阿拉伯数字
来源:互联网 发布:sjf调度算法代码 编辑:程序博客网 时间:2024/05/16 01:36
using Microsoft.VisualBasic;
public static string GetSpell(string strText)
{
string myStr = string.Empty;
for (int i = 0; i < strText.Length; i++)
{
myStr += GetFirstSpell(strText.Substring(i, 1));
}
return myStr;
}
private static string GetFirstSpell(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[] bmcode = { 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 = bmcode[i + 1];
if (bmcode[i] <= code && code < max)
{
return Encoding.Default.GetString(new byte[] { (byte)(65 + i) });
}
}
return "*";
}
else
{
return cnChar;
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
if (textBox1.Text == "")
listBox1.Visible = false;
else
listBox1.Visible = true;
//以下是拼音檢索
string strsql = "SELECT id,name FROM [PCMIS].[dbo].[DepartmentData] group by id,name ";
DataTable dtb = new DataTable();
dtb = SQL.command(strsql).Tables[0];
string[][] m_list_2 = new string[2][];
string m_list_1 = "";
string[] m_list;
m_list_2[0] = new string[dtb.Rows.Count];
m_list_2[1] = new string[dtb.Rows.Count];
for (int i = 0; i < dtb.Rows.Count; i++)
{
m_list_2[0][i] = dtb.Rows[i][0].ToString();
m_list_2[1][i] = dtb.Rows[i][1].ToString();
m_list_1 += m_list_2[0][i] + " " + m_list_2[1][i] + ",";
}
//繁简转换
string s_list = Strings.StrConv(m_list_1, VbStrConv.SimplifiedChinese, 0);
m_list = s_list.Split(',');
this.listBox1.Items.Clear();
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9/r/n]+");
if (!reg.Match(textBox1.Text.ToString()).Success)
{
//遍历ArrayList中的所有道路信息
foreach (object o in m_list)
{
//获得道路名称各汉字拼音首字母缩写,及阿拉伯数字
string strRoadName = GetSpell(o.ToString()).ToLower();
string strtxtRoadName = textBox1.Text.ToLower();
//根据拼音进行匹配(利用Contain和Substring函数进行判定)
if (strRoadName.Contains(strtxtRoadName) && strtxtRoadName.Substring(0, strtxtRoadName.Length) == strtxtRoadName)
{
listBox1.Items.Add(o);
}
}
}
else
{
//当TextBox为空时显示所有数据
return;
}
}
- C#中 利用汉字在计算机里面的编码来得到汉字的首拼音 及 阿拉伯数字
- C#中 利用汉字在计算机里面的编码来得到汉字的首拼音
- 利用汉字在计算机里面的编码来得到汉字的首拼音:
- 可以利用汉字在计算机里面的编码来的到汉字的首拼音
- 在C#中怎么得到汉字的拼音码
- C#中汉字数字、汉字拼音的转换
- C#中汉字数字、汉字拼音的转换
- c#的汉字转拼音
- c#的汉字转拼音
- C#读出汉字的拼音
- 计算机中汉字的二进制编码表示
- c# 汉字转拼音(完整的拼音)
- 在C#中取汉字的拼音码,支付数字、英文字符、一级汉字、二级汉字
- C#中获取汉字的GB2312编码
- c#中如何得到汉字的拼音首字母
- C#中按汉字的拼音排序建筑物名称
- c#取得汉字的拼音的首字母。
- C#取得汉字的拼音的首字母。
- 分享点NRF9E5资料吧
- Eclipse快捷键大全
- php md5加密
- 指针指向字符串和数组储存字符串区别
- 一个月总结
- C#中 利用汉字在计算机里面的编码来得到汉字的首拼音 及 阿拉伯数字
- sicily 1201 01000001
- In App Purchase 个人使用总结 2009 cocoachina
- sicily 2401 Judges' Time Calculation
- 在 MinGW 环境中使用 STLport 5.2.1
- ubuntu 环境,如何切换 Eclipse 的SubVersion 中保存的用户
- 教你如何使用Objective-C解析HTML!
- ARM、DSP、FPGA的区别
- sicily 2382 Flowers Flourish from France