勤奋菜鸟的天堂

导航

全角转半角

/// <summary>
        /// 全角转半角,(中文符号转英文符号)(DBC case)
        /// </summary>
        /// <param name="input">任意字符串</param>
        /// <returns>半角字符串</returns>
        private String ToDBC(String input)
        {
            char[] c = input.ToCharArray();
            for (int i = 0; i < c.Length; i++)
            {
                if (c[i] == 12288)
                {
                    c[i] = (char)32;
                    continue;
                }
                if (c[i] > 65280 && c[i] < 65375)
                    c[i] = (char)(c[i] - 65248);
            }
            return new String(c);
        }

posted on 2013-05-06 15:40  勤奋的菜鸟  阅读(171)  评论(0编辑  收藏  举报