/**//// <summary>
/// 半形轉全形
/// </summary>
/// <param name="BJstr"></param>
/// <returns></returns>
static public string GetQuanJiao(string BJstr)
...{
...#region
char[] c = BJstr.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] == 0)
...{
b[0] = (byte)(b[0] - 32);
b[1] = 255;
c[i] = System.Text.Encoding.Unicode.GetChars(b)[0];
}
}
}
string strNew = new string(c);
return strNew;
#endregion
}
/**//// <summary>
/// 全形轉半形
/// </summary>
/// <param name="QJstr"></param>
/// <returns></returns>
static public string GetBanJiao(string QJstr)
...{
...#region
char[] c = QJstr.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];
}
}
}
string strNew = new string(c);
return strNew;
#endregion
}
3、關於全形轉半形的問題,在Unicode中,標點、數字、字母的半形編碼最高位均為0,它們的全形編碼與半形編碼的第三位相差32h。