汉字转首拼

/// <summary>
        /// 字符串转首拼
        /// </summary>
        /// <param name="str">要转的汉字字符串</param>

       /// <param name="str">注*:添加ChnCharInfo.dll</param>
        /// <returns></returns>
        public string PYZG(string str)
        {
            
            char[] carr = str.ToCharArray();
            str =  new string(carr);
            string py = "";
            foreach (var item in str)
            {
                if (item >= 0x4e00 && item <= 0x9fbb)
                {
                    ChineseChar chn = new ChineseChar(item);
                    py += chn.Pinyins[0].Substring(0, 1).ToLower();
                }
                else
                {
                    py += item;
                }
            }
            py += DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
            return py;
        }



欢迎评论。。。。让我看到你的反馈。。。。

 

posted @ 2016-08-13 10:16  Smile丶品位  阅读(359)  评论(0编辑  收藏  举报