Skip to content

Instantly share code, notes, and snippets.

@curioustorvald
Created August 18, 2022 03:07
Show Gist options
  • Save curioustorvald/b68e60ce1dadcab9bc892c983f901880 to your computer and use it in GitHub Desktop.
Save curioustorvald/b68e60ce1dadcab9bc892c983f901880 to your computer and use it in GitHub Desktop.
Oesolise — 최현배식 푸러쓰기를 유니코드로 어떻게든 풀어 쓰기
function oesolise(string) {
const choseong = ['ᴊ','ᴊᴊ','ʟ','c','cc','ƨ','ᴅ','ᵾ','ᵾᵾ','ʌ','ʌʌ','','ʌ̅','ʌ̅ʌ̅','ƛ','ᴊ̵','ᴇ','z̵','ô']
const jungseong = ['h','hı','k','kı','q','qı','εլ','εլı','⊥','⊥̌h','⊥̌hı','⊥̌ı','⫫','ᴛ','ᴛq','ᴛqı','ᴛı','⫪','ᴜ','ᴜı','I']
const jongseong = ['','ᴊ','ᴊᴊ','ᴊʌ','ʟ','ʟʌ̅','ʟô','c','ƨ','ƨᴊ','ƨᴅ','ƨᵾ','ƨʌ','ƨᴇ','ƨz̵','ƨô','ᴅ','ᵾ','ᵾʌ','ʌ','ʌʌ','o','ʌ̅','ƛ','ᴊ̵','ᴇ','z̵','ô']
let outbuf = ''
const chars = [...string]
chars.map(it => it.codePointAt(0)).forEach(cp => {
if (0xAC00 <= cp && cp <= 0xD7A3) {
let base = cp - 0xAC00
let indexInitial = (base / 588)|0
let indexPeak = ((base / 28)|0) % 21
let indexFinal = base % 28
outbuf += choseong[indexInitial]
outbuf += jungseong[indexPeak]
outbuf += jongseong[indexFinal]
}
else {
outbuf += String.fromCodePoint(cp)
}
})
return outbuf
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment