Skip to content

Instantly share code, notes, and snippets.

@first087
Last active May 26, 2018 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save first087/90bebf806c3c3405898b9a3a20b02220 to your computer and use it in GitHub Desktop.
Save first087/90bebf806c3c3405898b9a3a20b02220 to your computer and use it in GitHub Desktop.
Convert thai number to arabic
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