Half-width conversion to full-angle to determine if it is full-width

Source: Internet
Author: User

#regionHalf-width conversion to full-width/// <summary>        ///Half-width conversion to full-width////Turn Full-width function (SBC case)///arbitrary string///Full-width space is 12288, half-width space is///other character half-width (33-126) and full-width (65281-65374) correspondence is: The difference between the 65248/// </summary>        /// <param name= "input" ></param>        /// <returns></returns>         Publicstring TOSBC (String input) {//half angle turn full angle:            Char[] C =input.            ToCharArray ();  for(inti =0; i < c.length; i++)            {                if(!iswhole (input)) {                    if(C[i] = = +)//Convert Spaces{C[i]= (Char)12288; Continue; }                    if(C[i] <127) C[i]= (Char) (C[i] +65248); }            }            return NewString (c); }        /// <summary>        ///determine if it is full-width/// </summary>        /// <param name= "checkstring" ></param>        /// <returns></returns>         Public BOOLIswhole (stringcheckstring) {            stringContainnumwords =@"^[a-z| A-z|0-9|\u4e00-\u9fa5\ ' ()]*$";//have alphanumeric characters space            returnRegex.IsMatch (checkstring, containnumwords); }        #endregion
View Code

Half-width conversion to full-angle to determine if it is full-width

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.