Skip to content

Instantly share code, notes, and snippets.

@Halkcyon
Created January 7, 2021 16:29
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 Halkcyon/6510818d0fa3f37a95d02533b7a272d9 to your computer and use it in GitHub Desktop.
Save Halkcyon/6510818d0fa3f37a95d02533b7a272d9 to your computer and use it in GitHub Desktop.
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