Last active
May 26, 2018 02:14
-
-
Save first087/90bebf806c3c3405898b9a3a20b02220 to your computer and use it in GitHub Desktop.
Convert thai number to arabic
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 src = ` | |
๑๒๓๔๕๖๗๘๙๐ | |
๑๒๓๔๕๖๗๘๙๐ | |
๑๒๓๔๕๖๗๘๙๐ | |
๑๒๓๔๕๖๗๘๙๐ | |
๑๒๓๔๕๖๗๘๙๐ | |
๑๒๓๔๕๖๗๘๙๐ | |
๑๒๓๔๕๖๗๘๙๐ | |
๑๒๓๔๕๖๗๘๙๐ | |
๑๒๓๔๕๖๗๘๙๐ | |
๑๒๓๔๕๖๗๘๙๐ | |
` | |
const dest = src.split('').map(ch => { | |
switch (ch) { | |
case '๑': return '1' | |
case '๒': return '2' | |
case '๓': return '3' | |
case '๔': return '4' | |
case '๕': return '5' | |
case '๖': return '6' | |
case '๗': return '7' | |
case '๘': return '8' | |
case '๙': return '9' | |
case '๐': return '0' | |
default: return ch | |
} | |
}).join('') | |
console.log(dest) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment