Skip to content

Instantly share code, notes, and snippets.

@iwstkhr
Created April 13, 2024 17:12
Show Gist options
  • Save iwstkhr/8ebdac1c90b499534962cd7896d55b64 to your computer and use it in GitHub Desktop.
Save iwstkhr/8ebdac1c90b499534962cd7896d55b64 to your computer and use it in GitHub Desktop.
Converting Japanese Hiragana to Katakana
def hiragana_to_katakana(src: str) -> str:
result = ''
for char in src:
code = ord(char)
result += chr(code + 96) if 12352 < code < 12439 else char
return result
print(hiragana_to_katakana('てすと'))
# It outputs 'テスト'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment