C#中英文記号相互回転(半角全角相互回転)
1393 ワード
#半角回転全角
#全角回転半角
///
///
/// 32, 12288
/// (33-126) (65281-65374) : 65248
///
///
///
public string ToSBC(string input)
{
char[] c = input.ToCharArray();
for (int i = 0; i < c.Length; i++)
{
if (c[i] == 32)
{
c[i] = (char)12288; continue;
}
if (c[i] < 127) c[i] = (char)(c[i] + 65248);
}
return new string(c);
}
#全角回転半角
///
///
/// 12288, 32
/// (33-126) (65281-65374) : 65248
///
///
///
public string ToDBC(string input)
{
char[] c = input.ToCharArray();
for (int i = 0; i < c.Length; i++)
{
if (c[i] == 12288)
{
c[i] = (char)32; continue;
}
if (c[i] > 65280 && c[i] < 65375)
c[i] = (char)(c[i] - 65248);
}
return new string(c);
}