汉字字符串如何转换成相对应的汉语拼音串? 没有这种功能,自己到网上找找有没有这种功能的com吧 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 将汉字转成拼音字头的方法“中华人民共和国”-->"ZHRMGHG" 是采用对应的区位的方法,但有些汉字不在这个范围里,大家试一下 public string hz2py(string hz) //获得汉字的区位码 { byte[] sarr = System.Text.Encoding.Default.GetBytes(hz); int len = sarr.Length; if (len>1) { byte[] array = new byte[2]; array = System.Text.Encoding.Default.GetBytes(hz); int i1 = (short)(array[0] - '\0'); int i2 = (short)(array[1] - '\0'); //unicode解码方式下的汉字码 // array = System.Text.Encoding.Unicode.GetBytes(hz); // int i1 = (short)(array[0] - '\0'); // int i2 = (short)(array[1] - '\0'); // int t1 = Convert.ToInt32(i1,16); // int t2 = Convert.ToInt32(i2,16); int tmp=i1*256+i2; string getpychar="*";//找不到拼音码的用*补位 if(tmp>=45217&&tmp<=45252){getpychar= "A";} else if(tmp>=45253&&tmp<=45760){getpychar= "B";} else if(tmp>=47761&&tmp<=46317){getpychar= "C";} else if(tmp>=46318&&tmp<=46825){getpychar= "D";} else if(tmp>=46826&&tmp<=47009){getpychar= "E";} else if(tmp>=47010&&tmp<=47296){getpychar= "F";} else if(tmp>=47297&&tmp<=47613){getpychar= "G";} else if(tmp>=47614&&tmp<=48118){getpychar= "H";} else if(tmp>=48119&&tmp<=49061){getpychar= "J";} else if(tmp>=49062&&tmp<=49323){getpychar= "K";} else if(tmp>=49324&&tmp<=49895){getpychar= "L";} else if(tmp>=49896&&tmp<=50370){getpychar= "M";} else if(tmp>=50371&&tmp<=50613){getpychar= "N";} else if(tmp>=50614&&tmp<=50621){getpychar= "O";} else if(tmp>=50622&&tmp<=50905){getpychar= "P";} else if(tmp>=50906&&tmp<=51386){getpychar= "Q";} else if(tmp>=51387&&tmp<=51445){getpychar= "R";} else if(tmp>=51446&&tmp<=52217){getpychar= "S";} else if(tmp>=52218&&tmp<=52697){getpychar= "T";} else if(tmp>=52698&&tmp<=52979){getpychar= "W";} else if(tmp>=52980&&tmp<=53640){getpychar= "X";} else if(tmp>=53689&&tmp<=54480){getpychar= "Y";} else if(tmp>=54481&&tmp<=55289){getpychar= "Z";} return getpychar; } else { return hz; } } public string transpy(string strhz) //把汉字字符串转换成拼音码 { string strtemp=""; int strlen=strhz.Length; for (int i=0;i<=strlen-1;i++) { strtemp+=hz2py(strhz.Substring(i,1)); } return strtemp; } 啊利版主的主页里有:http://www.zpcity.com/arli/下载:http://www.zpcity.com/arli/lib/py.zip 验证了路径之后还是找不到路径 的一部分,懵了,是不是.net的bug jquery取控件位置 请问:传值过程中的乱码怎么解决? asp与access使用的时候可以用数据返回框架吗? 为啥我的母板页上的背景图片不能显示? 问个xpath与dataSet的问题! rocklabzhang兄弟再次进来拿分!!! 一个偶觉得很难的问题 mailto;中的换行问题 讨论:如何在Response.Rediret另外一个页面后,再转回来时,还保持原来的状态 关于asp的设置虚拟目录的问题 如何精确的取得excel内的某一个单元格的值,并把它导入数据库内
{
byte[] sarr = System.Text.Encoding.Default.GetBytes(hz);
int len = sarr.Length;
if (len>1)
{
byte[] array = new byte[2];
array = System.Text.Encoding.Default.GetBytes(hz); int i1 = (short)(array[0] - '\0');
int i2 = (short)(array[1] - '\0'); //unicode解码方式下的汉字码
// array = System.Text.Encoding.Unicode.GetBytes(hz);
// int i1 = (short)(array[0] - '\0');
// int i2 = (short)(array[1] - '\0');
// int t1 = Convert.ToInt32(i1,16);
// int t2 = Convert.ToInt32(i2,16); int tmp=i1*256+i2;
string getpychar="*";//找不到拼音码的用*补位 if(tmp>=45217&&tmp<=45252){getpychar= "A";}
else if(tmp>=45253&&tmp<=45760){getpychar= "B";}
else if(tmp>=47761&&tmp<=46317){getpychar= "C";}
else if(tmp>=46318&&tmp<=46825){getpychar= "D";}
else if(tmp>=46826&&tmp<=47009){getpychar= "E";}
else if(tmp>=47010&&tmp<=47296){getpychar= "F";}
else if(tmp>=47297&&tmp<=47613){getpychar= "G";}
else if(tmp>=47614&&tmp<=48118){getpychar= "H";}
else if(tmp>=48119&&tmp<=49061){getpychar= "J";}
else if(tmp>=49062&&tmp<=49323){getpychar= "K";}
else if(tmp>=49324&&tmp<=49895){getpychar= "L";}
else if(tmp>=49896&&tmp<=50370){getpychar= "M";}
else if(tmp>=50371&&tmp<=50613){getpychar= "N";}
else if(tmp>=50614&&tmp<=50621){getpychar= "O";}
else if(tmp>=50622&&tmp<=50905){getpychar= "P";}
else if(tmp>=50906&&tmp<=51386){getpychar= "Q";}
else if(tmp>=51387&&tmp<=51445){getpychar= "R";}
else if(tmp>=51446&&tmp<=52217){getpychar= "S";}
else if(tmp>=52218&&tmp<=52697){getpychar= "T";}
else if(tmp>=52698&&tmp<=52979){getpychar= "W";}
else if(tmp>=52980&&tmp<=53640){getpychar= "X";}
else if(tmp>=53689&&tmp<=54480){getpychar= "Y";}
else if(tmp>=54481&&tmp<=55289){getpychar= "Z";}
return getpychar;
}
else
{
return hz;
}
} public string transpy(string strhz) //把汉字字符串转换成拼音码
{
string strtemp="";
int strlen=strhz.Length;
for (int i=0;i<=strlen-1;i++)
{
strtemp+=hz2py(strhz.Substring(i,1));
}
return strtemp;
}
http://www.zpcity.com/arli/
下载:
http://www.zpcity.com/arli/lib/py.zip