网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

汉字获取首字母拼音-创新互联

//获取字典 private Dictionary LoadPinYin(HttpContext context) { string link = context.Request.QueryString["link"]; Dictionary dic = new Dictionary(); DataTable dt = GetData();//获取数据库数据 foreach (DataRow row in dt.Rows) { if (row["idsName"].ToString() == "" || row["idsName"].ToString() == "其它") continue; string pinyin = ChineseCap(row["idsName"].ToString().Substring(0, 1)); if (dic.ContainsKey(pinyin)) { dic[pinyin] += string.Format("{0}", clsCommon.leftx(row["idsName"].ToString(), 10), Global.RewriteStaticUrl(link + "?idsid=" + row["idsID"].ToString()), row["idsName"].ToString()); } else { dic.Add(pinyin, string.Format("{0}", clsCommon.leftx(row["idsName"].ToString(), 10), Global.RewriteStaticUrl(link + "?idsid=" + row["idsID"].ToString()), row["idsName"].ToString())); } } return dic; } //转换 public string ChineseCap(string ChineseStr) { string Capstr = string.Empty; byte[] ZW = new byte[2]; long ChineseStr_int; string CharStr, ChinaStr = ""; for (int i = 0; i <= ChineseStr.Length - 1; i++) { CharStr = ChineseStr.Substring(i, 1).ToString(); ZW = System.Text.Encoding.Default.GetBytes(CharStr); // 得到汉字符的字节数组 if (ZW.Length == 2) { int i1 = (short)(ZW[0]); int i2 = (short)(ZW[1]); ChineseStr_int = i1 * 256 + i2; if ((ChineseStr_int >= 45217) && (ChineseStr_int <= 45252)) { ChinaStr = "A"; } else if ((ChineseStr_int >= 45253) && (ChineseStr_int <= 45760)) { ChinaStr = "B"; } else if ((ChineseStr_int >= 45761) && (ChineseStr_int <= 46317)) { ChinaStr = "C"; } else if ((ChineseStr_int >= 46318) && (ChineseStr_int <= 46825)) { ChinaStr = "D"; } else if ((ChineseStr_int >= 46826) && (ChineseStr_int <= 47009)) { ChinaStr = "E"; } else if ((ChineseStr_int >= 47010) && (ChineseStr_int <= 47296)) { ChinaStr = "F"; } else if ((ChineseStr_int >= 47297) && (ChineseStr_int <= 47613)) { ChinaStr = "G"; } else if ((ChineseStr_int >= 47614) && (ChineseStr_int <= 48118)) { ChinaStr = "H"; } else if ((ChineseStr_int >= 48119) && (ChineseStr_int <= 49061)) { ChinaStr = "J"; } else if ((ChineseStr_int >= 49062) && (ChineseStr_int <= 49323)) { ChinaStr = "K"; } else if ((ChineseStr_int >= 49324) && (ChineseStr_int <= 49895)) { ChinaStr = "L"; } else if ((ChineseStr_int >= 49896) && (ChineseStr_int <= 50370)) { ChinaStr = "M"; } else if ((ChineseStr_int >= 50371) && (ChineseStr_int <= 50613)) { ChinaStr = "N"; } else if ((ChineseStr_int >= 50614) && (ChineseStr_int <= 50621)) { ChinaStr = "O"; } else if ((ChineseStr_int >= 50622) && (ChineseStr_int <= 50905)) { ChinaStr = "P"; } else if ((ChineseStr_int >= 50906) && (ChineseStr_int <= 51386)) { ChinaStr = "Q"; } else if ((ChineseStr_int >= 51387) && (ChineseStr_int <= 51445)) { ChinaStr = "R"; } else if ((ChineseStr_int >= 51446) && (ChineseStr_int <= 52217)) { ChinaStr = "S"; } else if ((ChineseStr_int >= 52218) && (ChineseStr_int <= 52697)) { ChinaStr = "T"; } else if ((ChineseStr_int >= 52698) && (ChineseStr_int <= 52979)) { ChinaStr = "W"; } else if ((ChineseStr_int >= 52980) && (ChineseStr_int <= 53640)) { ChinaStr = "X"; } else if ((ChineseStr_int >= 53689) && (ChineseStr_int <= 54480)) { ChinaStr = "Y"; } else if ((ChineseStr_int >= 54481) && (ChineseStr_int <= 55289)) { ChinaStr = "Z"; } } else { Capstr = ChineseStr; break; } Capstr = Capstr + ChinaStr; } return Capstr; }
新闻标题:汉字获取首字母拼音-创新互联
链接分享:http://bjjierui.cn/article/ccccoc.html

其他资讯