zoukankan      html  css  js  c++  java
  • 汉字转拼音 城市绑定

    引用 程序集

    ChnCharInfo.dll

    using Microsoft.International.Converters.PinYinConverter;

    转换方法

    public static string ToPinyin(string hanzi)
            {
                char[] ch = hanzi.ToArray();
                string pinyinStr = "";
                foreach (char c in ch)
                {
                    if (ChineseChar.IsValidChar(c))
                    {
                        ChineseChar chineseChar = new ChineseChar(c);
                        ReadOnlyCollection<string> pinyin = chineseChar.Pinyins;
                        pinyinStr += (pinyin[0].Substring(0, pinyin[0].Length - 1));
                    }
                    else
                    {
                        pinyinStr += c.ToString();
                    }
                }
                return pinyinStr.ToLower();
            }

    城市绑定的特殊效果

    <div id="con_province_2" style="display: none;">
                                    <ul class="cdcomment">
                                        @{
                                            foreach (Entity.TXDai.Provinces item in Provinces)
                                            {
                                                string pinyinStr = Common.ToPinyin(item.Province);
                                                if (pinyinStr[0] == 'a' || pinyinStr[0] == 'b' || pinyinStr[0] == 'c' || pinyinStr[0] == 'd' || pinyinStr[0] == 'f')
                                                {
                                            <li><a href="javascript:void(0);" data="@item.ProvinceID">@item.Province</a></li>
                                                }
                                            }
                                        }
                                    </ul>
                                </div>

  • 相关阅读:
    oracle update join
    ResultSet转换为List的方法
    oracle创建用户操作
    ArcGIS打开工具无响应
    当前不会命中断点。源代码与原始版本不同
    使用Skin Editor自定义主题皮肤
    Spring boot项目设置加载静态资源的路径(spring.resources.static-locations)
    linux下文件的复制、移动与删除
    【珍藏】清华大学状元笔记 (初中+高中)全套高清笔记电子版 PDF
    【珍藏】全付费 (共204本)图灵程序设计丛书 高清电子书 带书签 PDF
  • 原文地址:https://www.cnblogs.com/eric-gms/p/4054203.html
Copyright © 2011-2022 走看看