Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. function toFarsiDigit(number) {
  2. const regex = /[0-9]/g
  3. let result = number.replace(regex, function (w) {
  4. return String.fromCharCode(w.charCodeAt(0) + 1728)
  5. })
  6.  
  7. return result
  8. }
  9.  
  10. function toEnglishDigit(number) {
  11. const regex = /[۰−۹]/g
  12. let result = number.replace(regex, function (w) {
  13. return String.fromCharCode(w.charCodeAt(0) - 1728)
  14. })
  15.  
  16. return result
  17. }
  18.  
  19. exports.toEnglishDigit = toEnglishDigit
  20. exports.toFarsiDigit = toFarsiDigit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement