Last active
September 3, 2020 11:09
-
-
Save frankrolf/16108a30841d848fd41f5264a8200abc to your computer and use it in GitHub Desktop.
Table-flip any phrase you like! (╯°□°)╯︵ ǝsɐɹɥd
This file contains 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
''' | |
table-flip any phrase you like! | |
If the expression contains spaces, please use quotes. | |
python flip_phrase.py fontlab | |
>>> (╯°□°)╯︵ qɐlʇuoɟ | |
''' | |
import sys | |
import unicodedata | |
unflipped = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ' | |
flipped = '∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Zɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz0ƖᄅƐㄣϛ9ㄥ86 ' | |
flipping_guy = '(╯°□°)╯︵ ' | |
input_text = sys.argv[-1] | |
input_text_ascii = unicodedata.normalize( | |
'NFD', input_text).encode('ascii', 'ignore') | |
output_flipped = '' | |
for ch_code in input_text_ascii: | |
ch = chr(ch_code) | |
try: | |
ch_index = unflipped.index(ch) | |
ch_flipped = flipped[ch_index] | |
except ValueError: | |
ch_flipped = ch | |
output_flipped += ch_flipped | |
print(flipping_guy + output_flipped[::-1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment