Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import unicodedata
- from string import ascii_lowercase, ascii_uppercase
- def italic(text):
- lower = "MATHEMATICAL BOLD ITALIC SMALL {}"
- upper = "MATHEMATICAL BOLD ITALIC CAPITAL {}"
- result = []
- for char in text:
- if char.islower() and char in ascii_lowercase:
- result.append(unicodedata.lookup(lower.format(char)))
- elif char.isupper() and char in ascii_uppercase:
- result.append(unicodedata.lookup(upper.format(char)))
- else:
- result.append(char)
- return "".join(result)
- def normalize(text):
- return unicodedata.normalize("NFKC", text)
Add Comment
Please, Sign In to add comment