Created
April 13, 2024 17:12
-
-
Save iwstkhr/8ebdac1c90b499534962cd7896d55b64 to your computer and use it in GitHub Desktop.
Converting Japanese Hiragana to Katakana
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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