网站建议:179001057@qq.com

全角字符转换成半角字符

技术2022-05-11  0

public static string CharConverter(string source)        {            System.Text.StringBuilder result = new System.Text.StringBuilder(source.Length, source.Length);            for (int i = 0; i < source.Length; i++)            {                if (source[i] >= 65281 && source[i] <= 65373)                {                    result.Append((char)(source[i] - 65248));                }                else if (source[i] == 12288)                {                    result.Append(' ');                }                else                {                    result.Append(source[i]);                }            }            return result.ToString();        }

最新回复(0)