Last active
July 12, 2021 12:30
-
-
Save hasanisaeed/ff5cbf67c1ee3bd513423e9896f7073d to your computer and use it in GitHub Desktop.
Convert Persian digits to English digits.
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
fa2EnDigits(str) { | |
str = String(str); | |
var e = '۰'.charCodeAt(0); | |
str = str.replace(/[۰-۹]/g, function (t) { | |
return t.charCodeAt(0) - e; | |
}); | |
e = '٠'.charCodeAt(0); | |
str = str.replace(/[٠-٩]/g, function (t) { | |
return t.charCodeAt(0) - e; | |
}); | |
return str; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment