Skip to content

Instantly share code, notes, and snippets.

@masoudgs
Last active December 26, 2016 19:24
Show Gist options
  • Select an option

  • Save masoudgs/a794fdfc0359831dc5a06c9558ce1eea to your computer and use it in GitHub Desktop.

Select an option

Save masoudgs/a794fdfc0359831dc5a06c9558ce1eea to your computer and use it in GitHub Desktop.

Revisions

  1. Masoud Ghorbani renamed this gist Dec 26, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion english-farsi-digiter.js → english-farsi-converter.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ function toFarsiDigit(number) {
    }

    function toEnglishDigit(number) {
    const regex = /[۰۹]/g
    const regex = /[\u0660-\u0669\u06F0-\u06F9]/g
    let result = number.replace(regex, function (w) {
    return String.fromCharCode(w.charCodeAt(0) - 1728)
    })
  2. @mcrunix mcrunix revised this gist Dec 8, 2016. 2 changed files with 20 additions and 10 deletions.
    10 changes: 0 additions & 10 deletions english-digits-to-farsi.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +0,0 @@
    function toFarsiDigit(number) {
    const regex = /[0-9]/g
    let result = number.replace(regex, function (w) {
    return String.fromCharCode(w.charCodeAt(0) + 1728)
    })

    return result
    }

    exports.toFarsiDigit = toFarsiDigit
    20 changes: 20 additions & 0 deletions english-farsi-digiter.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    function toFarsiDigit(number) {
    const regex = /[0-9]/g
    let result = number.replace(regex, function (w) {
    return String.fromCharCode(w.charCodeAt(0) + 1728)
    })

    return result
    }

    function toEnglishDigit(number) {
    const regex = /[۰۹]/g
    let result = number.replace(regex, function (w) {
    return String.fromCharCode(w.charCodeAt(0) - 1728)
    })

    return result
    }

    exports.toEnglishDigit = toEnglishDigit
    exports.toFarsiDigit = toFarsiDigit
  3. @mcrunix mcrunix created this gist Dec 8, 2016.
    10 changes: 10 additions & 0 deletions english-digits-to-farsi.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    function toFarsiDigit(number) {
    const regex = /[0-9]/g
    let result = number.replace(regex, function (w) {
    return String.fromCharCode(w.charCodeAt(0) + 1728)
    })

    return result
    }

    exports.toFarsiDigit = toFarsiDigit