Skip to content

Instantly share code, notes, and snippets.

@hasanisaeed
Last active July 12, 2021 12:30
Show Gist options
  • Save hasanisaeed/ff5cbf67c1ee3bd513423e9896f7073d to your computer and use it in GitHub Desktop.
Save hasanisaeed/ff5cbf67c1ee3bd513423e9896f7073d to your computer and use it in GitHub Desktop.
Convert Persian digits to English digits.
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