The automatic switching of angle and half-width characters, select a textbox on the form to automatically switch to Chinese characters to enter Chinese characters, select another textbox and automatically switch to the English input state to enter half-width characters.
Textbox.imemode = Imemode.on; Open IME
Textbox.imemode = Imemode.off; Close IME
#region Full angle Half angle conversion
<summary>
A function that turns the whole corner (SBC case)
</summary>
<param name= "Input" > arbitrary string </param>
<returns> full-angle string </returns>
<remarks>
Full-width spaces are 12288, half-width spaces are 32
The corresponding relation of the other character half angle (33-126) and the whole angle (65281-65374) is: The difference is 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> function (DBC case) </summary>
<param name= "Input" > arbitrary string </param>
<returns> half-corner string </returns>
<remarks>
Full-width spaces are 12288, half-width spaces are 32
The corresponding relation of the other character half angle (33-126) and the whole angle (65281-65374) is: The difference is 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