using System;
using System.Collections.Generic;
using System.Text;
namespace talefox.ShareLib
{
public class Characters
{
/// <summary>
/// 全角转半角
/// </summary>
/// <param name="c">需要转换的字符,当为半角时不转换</param>
/// <returns>半角字符</returns>
public static char DoubleByteToHalfAngle(char c)
{
char[] cs = new char[] { c};
byte[] bs = System.Text.Encoding.Unicode.GetBytes(cs, 0, 1);
if (bs.Length == 2)
{
if (bs[1] == 255)
{
bs[0] = (byte)(bs[0] + 32);
bs[1] = 0;
cs[0] = System.Text.Encoding.Unicode.GetChars(bs)[0];
}
}
return cs[0];
}
}
}