Skip to content

Instantly share code, notes, and snippets.

@munierujp
Last active March 12, 2021 08:50
Show Gist options
  • Save munierujp/8b68860fb671bd4bab1b556e510eb87f to your computer and use it in GitHub Desktop.
Save munierujp/8b68860fb671bd4bab1b556e510eb87f to your computer and use it in GitHub Desktop.
const KATAKANA_PATTERN = /[\u30A1-\u30FA]/g
function convertKatakanaToHiragana (katakana: string): string {
return katakana.replace(KATAKANA_PATTERN, toHiragana)
}
function toHiragana (katakana: string): string {
const code = katakana.charCodeAt(0) - 0x60
return String.fromCharCode(code)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment