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

            }
  • 相关阅读:
    js数组的常见操作( push、pop、unshift、shift、splice、concat、 join)的用法
    js json对象与字符串转换
    js回调函数(callback)
    Array数组 [] 遍历方法
    65.rem布局详解(一图流)
    关于内存泄漏
    JS精粹知识点和我的解释
    再谈布局2-Flex布局
    input和button不同高 和 rem
    正则表达式学习
  • 原文地址:https://www.cnblogs.com/lds85930/p/1207751.html
Copyright © 2011-2022 走看看