Skip to content

Instantly share code, notes, and snippets.

@riceissa
Last active August 1, 2020 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riceissa/a6f0dd2f88bbb334701e551d8481efd2 to your computer and use it in GitHub Desktop.
Save riceissa/a6f0dd2f88bbb334701e551d8481efd2 to your computer and use it in GitHub Desktop.
Convert Unicode "MATHEMATICAL SANS-SERIF ITALIC" letters to their ASCII equivalents
#!/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