Last active
August 1, 2020 06:43
-
-
Save riceissa/a6f0dd2f88bbb334701e551d8481efd2 to your computer and use it in GitHub Desktop.
Convert Unicode "MATHEMATICAL SANS-SERIF ITALIC" letters to their ASCII equivalents
This file contains hidden or 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
#!/usr/bin/env python3 | |
# Use like this: | |
# cat file.txt | ./de_italicize.py | |
import sys | |
italic_lowercase_a = '𝘢' | |
italic_uppercase_a = '𝘈' | |
for line in sys.stdin: | |
good_line = "" | |
for c in line: | |
if ord(c) in range(ord(italic_lowercase_a), ord(italic_lowercase_a)+26+1): | |
good_line += chr(ord('a') + ord(c) - ord(italic_lowercase_a)) | |
elif ord(c) in range(ord(italic_uppercase_a), ord(italic_uppercase_a)+26+1): | |
good_line += chr(ord('A') + ord(c) - ord(italic_uppercase_a)) | |
else: | |
good_line += c | |
print(good_line, end='') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment