Skip to content

Instantly share code, notes, and snippets.

@seanghay
Last active October 16, 2022 15:16
Show Gist options
  • Select an option

  • Save seanghay/26e7d8293d3285f2984dd411b87d471a to your computer and use it in GitHub Desktop.

Select an option

Save seanghay/26e7d8293d3285f2984dd411b87d471a to your computer and use it in GitHub Desktop.

Revisions

  1. seanghay revised this gist Oct 16, 2022. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions khmer-number.js
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,4 @@
    const khmer2ascii = (s) =>
    [...s].reduce((p, c) => p + (c = c.charCodeAt(0), String.fromCharCode(c >= 6112 && c <= 6121 ? c - 6064 : c)), '')
    const km2ascii = (s) =>[...s].reduce((p,c)=>p+(c=c.charCodeAt(0),String.fromCharCode(c-(c>=6112&&c<=6121?6064:0))),'')

    km2ascii('1234abc១២៣៤')
    // => '1234abc1234'
  2. seanghay created this gist Oct 16, 2022.
    2 changes: 2 additions & 0 deletions khmer-number.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    const khmer2ascii = (s) =>
    [...s].reduce((p, c) => p + (c = c.charCodeAt(0), String.fromCharCode(c >= 6112 && c <= 6121 ? c - 6064 : c)), '')