Full-width halfwidth Conversion

Source: Internet
Author: User

/** <Summary>
/// Function for converting the fullwidth (SBC case)
/// </Summary>
/// <Param name = "input"> any string </param>
/// <Returns> fullwidth string </returns>
**/
Public string ToSBC (string input)
{
// Halfwidth to fullwidth:
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>
/// Returns a function (DBC case)
/// </Summary>
/// <Param name = "input"> any string </param>
/// <Returns> halfwidth string </returns>
**/
Public 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 );
}
 
Author: ERDP Technical Architecture"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.