public static string FullWidthToHalfWidth(string str)
{
byte[] t = Encoding.Default.GetBytes(str);
for (int i = 0; i < t.Length; i++)
{
if ((t[i].ToString() == "161") && (t[i + 1].ToString() == "161"))
{
t[i] = 32;
if (i + 1 == t.Length - 1)
{
t[i + 1] = 0;
}
else
{
for (int j = i + 1; j + 1 < t.Length; j++)
{
t[j] = t[j + 1];
if (j + 1 == t.Length - 1)
{
t[j + 1] = 0;
}
}
}
}
}
return Encoding.Default.GetString(t);
}
转载于:https://www.cnblogs.com/yeye518/archive/2011/08/11/2231622.html