1
/// <summary>
2
/// 转全角的函数(SBC case)
3
/// </summary>
4
/// <param name="input">任意字符串</param>
5
/// <returns>全角字符串</returns>
6
///<remarks>
7
///全角空格为12288,半角空格为32
8
///其他字符半角(33-126)与全角(65281-65374)的对应关系是:均相差65248
9
///</remarks>
10
public string ToSBC(string input)
11
{
12
//半角转全角:
13
char[] c=input.ToCharArray();
14
for (int i = 0; i < c.Length; i++)
15
{
16
if (c[i]==32)
17
{
18
c[i]=(char)12288;
19
continue;
20
}
21
if (c[i]<127)
22
c[i]=(char)(c[i]+65248);
23
}
24
return new string(c);
25
}
26![](/Images/OutliningIndicators/None.gif)
27![](/Images/OutliningIndicators/None.gif)
28
/// <summary>
29
/// 转半角的函数(DBC case)
30
/// </summary>
31
/// <param name="input">任意字符串</param>
32
/// <returns>半角字符串</returns>
33
///<remarks>
34
///全角空格为12288,半角空格为32
35
///其他字符半角(33-126)与全角(65281-65374)的对应关系是:均相差65248
36
///</remarks>
37
public string ToDBC(string input)
38
{
39
char[] c=input.ToCharArray();
40
for (int i = 0; i < c.Length; i++)
41
{
42
if (c[i]==12288)
43
{
44
c[i]= (char)32;
45
continue;
46
}
47
if (c[i]>65280 && c[i]<65375)
48
c[i]=(char)(c[i]-65248);
49
}
50
return new string(c);
51
}
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
2
![](/Images/OutliningIndicators/InBlock.gif)
3
![](/Images/OutliningIndicators/InBlock.gif)
4
![](/Images/OutliningIndicators/InBlock.gif)
5
![](/Images/OutliningIndicators/InBlock.gif)
6
![](/Images/OutliningIndicators/InBlock.gif)
7
![](/Images/OutliningIndicators/InBlock.gif)
8
![](/Images/OutliningIndicators/InBlock.gif)
9
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
10
![](/Images/OutliningIndicators/None.gif)
11
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
26
![](/Images/OutliningIndicators/None.gif)
27
![](/Images/OutliningIndicators/None.gif)
28
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/InBlock.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/InBlock.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/InBlock.gif)
36
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
37
![](/Images/OutliningIndicators/None.gif)
38
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/InBlock.gif)
41
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
42
![](/Images/OutliningIndicators/InBlock.gif)
43
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
44
![](/Images/OutliningIndicators/InBlock.gif)
45
![](/Images/OutliningIndicators/InBlock.gif)
46
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
47
![](/Images/OutliningIndicators/InBlock.gif)
48
![](/Images/OutliningIndicators/InBlock.gif)
49
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
50
![](/Images/OutliningIndicators/InBlock.gif)
51
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)