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 冒泡排序代码
    随机数生成机制
    C#学习成果 兔子计算
    C#学习成果 质数判断
    3.24学习成果
    制作登录界面,登录成功后把用户名放在session里,在第3个页面读取session显示用户名
    编写一个简易的留言薄,实现添加留言和显示留言内容等功能
    编写一个jsp程序,实现用户登录,当用户输入的用户或密码错误时,将页面重定向到错误提示页,并在该页面显示30秒后 自动回到用户登录界面
    jsp输出当前时间
    jsp输出九九乘法表
  • 原文地址:https://www.cnblogs.com/lds85930/p/1207751.html
Copyright © 2011-2022 走看看