C full Angle half Angle conversion function code sharing
- 2020-05-19 05:36:30
- OfStack
/// <summary>
/// It's a function of the total Angle of rotation (SBC case)
/// </summary>
/// <param name="input"> Arbitrary string </param>
/// <returns> Full Angle string </returns>
///<remarks>
/// The full space is 12288 , half corner space is 32
/// Other characters are half corners (33-126) With the Angle of (65281-65374) The corresponding relation is: mean difference 65248
///</remarks>
public static string ToSBC(string input)
{
// Half Angle to full Angle:
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);
}
/// <summary> It's a function of the half Angle (DBC case) </summary>
/// <param name="input"> Arbitrary string </param>
/// <returns> Half Angle string </returns>
///<remarks>
/// The full space is 12288 , half corner space is 32
/// Other characters are half corners (33-126) With the Angle of (65281-65374) The corresponding relation is: mean difference 65248
///</remarks>
public static 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);
}
#endregion