Forked from heeju/japanese-full-to-half-method.js
Created
September 22, 2020 02:30
-
-
Save vdloc/7f159545cbd7ce1e9a050bbd43572043 to your computer and use it in GitHub Desktop.
Convert full-width Japanese character to half-width ascii character
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String.prototype.toHalfWidth = function() { | |
| return this.replace(/[!-~]/g, function(r){ | |
| return String.fromCharCode(r.charCodeAt(0) - 0xFEE0); | |
| }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const convertFullToHalf = str => str.replace(/[!-~]/g, r => String.fromCharCode(r.charCodeAt(0) - 0xFEE0)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment