• 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

            }
  • 相关阅读:
    【原创】NOR FLASH Block Unprotection
    虚拟机:Snapshot
    Struts2:简单登陆验证DAO VO ACTION
    Cocos2dx:安装
    LoadRunner:Socket+Http协议
    LoadRunner中添加外部文件(md5.h),使用MD5
    Javascript实现网页水印(非图片水印)
    ASP.NET网站限制访问频率
    再谈“ASP.NET网站限制恶意访问”
    【新闻】“赢在淘宝”b比赛 30强、10强火热出炉~!
  • 原文地址:https://www.cnblogs.com/lds85930/p/1207751.html
Copyright © 2020-2023  润新知