Created
January 7, 2021 16:29
-
-
Save Halkcyon/6510818d0fa3f37a95d02533b7a272d9 to your computer and use it in GitHub Desktop.
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
A_SCRIPT_CAPS = ord("\N{MATHEMATICAL BOLD SCRIPT CAPITAL A}") | |
A_SCRIPT_SMALL = ord("\N{MATHEMATICAL BOLD SCRIPT SMALL A}") | |
A_CAPS = ord('A') | |
A_SMALL = ord('a') | |
RANGE_CAPS = range(A_CAPS, A_CAPS+26) | |
RANGE_SMALL = range(A_SMALL, A_SMALL+26) | |
def cursive(s: str) -> str: | |
for i, v in enumerate(chars := list(map(ord, s))): | |
if v in RANGE_CAPS: | |
chars[i] = A_SCRIPT_CAPS + (v - A_CAPS) | |
elif v in RANGE_SMALL: | |
chars[i] = A_SCRIPT_SMALL + (v - A_SMALL) | |
return ''.join(map(chr, chars)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment