/// 转全角的函数(SBC case) ///
///
任意字符串
///
全角字符串 ///
///全角空格为半角空格为///其他字符半角()与全角()的对应关系是均相差 ///
public string ToSBC(string input)
{ //半角转全角
char[] c=inputToCharArray();
for (int i = ; i < cLength; i++)
{
if (c[i]==)
{
c[i]=(char); continue;
}
if (c[i]<) c[i]=(char)(c[i]+);
}
return new string(c);
}
/// /// 转半角的函数(DBC case) ///
///
任意字符串
/// 半角字符串 ///
///全角空格为半角空格为 ///其他字符半角()与全角()的对应关系是均相差 ///
public string ToDBC(string input)
{
char[] c=inputToCharArray();
for (int i = ; i < cLength; i++)
{
if (c[i]==)
{
c[i]= (char); continue;
}
if (c[i]> && c[i]<)
c[i]=(char)(c[i]);
}
return new string(c);
}
VB版本
Public Function ToSBC()Function ToSBC(ByVal input As String) As String 转全角 Dim c As Char() = inputToCharArray Dim i As Integer = While i < cLength If c(i) = ChrW() Then c(i) = ChrW() ElseIf AscW(c(i)) < Then c(i) = ChrW((AscW(c(i)) + )) End If SystemMathMin(SystemThreadingInterlockedIncrement(i) i ) End While Return New String(c) End Function Public Function ToDBC()Function ToDBC(ByVal input As String) As String 转半角 Dim c As Char() = inputToCharArray Dim i As Integer = While i < cLength If AscW(c(i)) = Then c(i) = ChrW() ElseIf AscW(c(i)) > AndAlso AscW(c(i)) < Then c(i) = ChrW(AscW(c(i)) ) End If SystemMathMin(SystemThreadingInterlockedIncrement(i) i ) End While Return New String(c) End Function