c# 删除去掉全角空格

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 20:14   2787   0
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

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP