C# 全角符号转半角

 1    public static string SBCCaseToNumberic(string SBCCase)
 2         {
 3             char[] c = SBCCase.ToCharArray();
 4             for (int i = 0; i < c.Length; i++)
 5             {
 6                 byte[] b = System.Text.Encoding.Unicode.GetBytes(c, i, 1);
 7                 if (b.Length == 2)
 8                 {
 9                     if (b[1] == 255)
10                     {
11                         b[0] = (byte)(b[0] + 32);
12                         b[1] = 0;
13                         c[i] = System.Text.Encoding.Unicode.GetChars(b)[0];
14                     }
15                 }
16             }
17             return new string(c);
18         }

 

posted @ 2015-09-02 17:23  一碗豆芽汤(OneV)  阅读(238)  评论(0编辑  收藏  举报