The method of realizing full angle turning half angle with javascript _javascript technique

Source: Internet
Author: User

In this paper, we illustrate the method of JavaScript to realize full angle turning half angle. Share to everyone for your reference, specific as follows:

function Fullchar2halfchar (str)
{
 var result = ';
 for (i=0; i<str.length; i++)
 {
 code = str.charcodeat (i);//Get the Unicode encoding of the current character
 if (code >= 65281 && Amp Code <= 65373//In this Unicode encoding range is all the English letters have been various characters
 {result
  + + string.fromcharcode (str.charcodeat (i)-65248) ;//Convert Unicode encoding of full-width characters to the corresponding Half-width character Unicode code
 }else if (code = = 12288)/space
 {result
  + = String.fromCharCode ( Str.charcodeat (i)-12288 +);
 } else
 {Result
  = Str.charat (i);
 }
 }
 return result;
}

I hope this article will help you with JavaScript programming.

Related Article

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.