Skip to content

Instantly share code, notes, and snippets.

@pisceanfoot
Created June 28, 2014 06:01
Show Gist options
  • Save pisceanfoot/ea0717278e35e2a0c185 to your computer and use it in GitHub Desktop.
Save pisceanfoot/ea0717278e35e2a0c185 to your computer and use it in GitHub Desktop.
将全角数字转换为数字
/// <summary>
/// 将全角数字转换为数字
/// </summary>
/// <param name="SBCCase"></param>
/// <returns></returns>
public string SBCCaseToNumberic(string SBCCase)
{
char[] c = SBCCase.ToCharArray();
for (int i = 0; i < c.Length; i++)
{
byte[] b = System.Text.Encoding.Unicode.GetBytes(c, i, 1);
if (b.Length == 2)
{
if (b[1] == 255)
{
b[0] = (byte)(b[0] + 32);
b[1] = 0;
c[i] = System.Text.Encoding.Unicode.GetChars(b)[0];
}
}
}
return new string(c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment