zoukankan      html  css  js  c++  java
  • 汉字换成拼音码

    public static string GetChinesePell(string chinese)
            {
                string tempChar = "";
                char[] temp = chinese.ToCharArray();
                for (int i = 0; i < temp.Length; i++)
                {
                    byte[] arrCN = Encoding.Default.GetBytes(temp[i].ToString());
                    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 j = 0; j < 26; j++)
                        {
                            int max = 55290;
                            if (j != 25) max = areacode[j + 1];
                            if (areacode[j] <= code && code < max)
                            {
                                tempChar += Encoding.Default.GetString(new byte[] { (byte)(65 + j) }).ToLower();
                            }
                        }
                    }
                    else
                    {
                        tempChar += temp[i];
                    }
                }
                return tempChar;
            }

  • 相关阅读:
    asp.net core 3.1 CreateDefaultBuilder默认启动解析
    VS2019安装扩展成功后,扩展不显示(未启用,也找不到选项)
    Redis持久化必知必会
    调试错误,请回到请求来源地,重新发起请求
    复制DataRow行 插入DataTabel
    mysql查看被锁住的表
    RedisHelper帮助类(转)
    C#接口的作用实例解析
    ASP.NET CORE 启动过程及源码解读(转)
    医疗行业&产品/技术交流群
  • 原文地址:https://www.cnblogs.com/http-www/p/3413744.html
Copyright © 2011-2022 走看看