zoukankan      html  css  js  c++  java
  • c# asp.net 2.0 获取汉字第一个拼音

    /// <summary>
            
    /// 获取汉字第一个拼音
            
    /// </summary>
            
    /// <param name="input"></param>
            
    /// <returns></returns>

            static public string getSpells(string input)
            
    {
                
    #region
                
    int len = input.Length;
                
    string reVal = "";
                
    for (int i = 0; i < len; i++)
                
    {
                    reVal 
    += getSpell(input.Substring(i, 1));
                }

                
    return reVal;
                
    #endregion

            }


            
    static public string getSpell(string cn)
            
    {
                
    #region
                
    byte[] arrCN = Encoding.Default.GetBytes(cn);
                
    if (arrCN.Length > 1)
                
    {
                    
    int area = (short)arrCN[0];
                    
    int pos = (short)arrCN[1];
                    
    int code = (area << 8+ pos;
                    
    int[] areacode = 4521745253457614631846826470104729747614481194811949062493244989650371506145062250906513875144652218526985269852698529805368954481 };
                    
    for (int i = 0; i < 26; i++)
                    
    {
                        
    int max = 55290;
                        
    if (i != 25) max = areacode[i + 1];
                        
    if (areacode[i] <= code && code < max)
                        
    {
                            
    return Encoding.Default.GetString(new byte[] { (byte)(65 + i) });
                        }

                    }

                    
    return "?";
                }

                
    else return cn;
                
    #endregion

            }
  • 相关阅读:
    Java实现直接插入查找
    CSS hack常用方案(摘选)
    输入一个字符串,去掉重复的字符,并按ASCII值排序-华为机试
    git操作github
    简单记录下idea上配置spring
    mysql国内镜像下载网址
    tomcat启动不成功(点击startup.bat闪退)的解决办法
    Encode and Decode TinyURL
    leetcode 4Sum II
    leetcode two sum
  • 原文地址:https://www.cnblogs.com/lds85930/p/1207751.html
Copyright © 2011-2022 走看看