Javascript implements full-width-to-half-width conversion, and javascript full-width conversion
This article describes how to implement full-width and half-width conversion in javascript. We will share this with you for your reference. The details are as follows:
Function fullChar2halfChar (str) {var result = ''; for (I = 0; I <str. length; I ++) {code = str. charCodeAt (I); // obtain the unicode code of the current character if (code >=65281 & code <= 65373) // In this unicode encoding range, all English letters have various characters {result + = String. fromCharCode (str. charCodeAt (I)-65248); // converts the unicode code of the full-width character to the unicode code of the corresponding half-width character} else if (code = 12288) // space {result + = String. fromCharCode (str. charCodeAt (I)-12288 + 32);} else {result + = str. charAt (I) ;}} return result ;}
I hope this article will help you design JavaScript programs.
Articles you may be interested in:
- Javascript method for full-width half-width Detection
- Javascript converts fullwidth and halfwidth characters
- JavaScript fullwidth to halfwidth
- Js functions for full-width conversion
- Asp (javascript) full-width half-width conversion code dbc2sbc
- Js determines the browser type and closes the current window automatically when the width and space of the browser are removed.