Coding STEM

True text transformation without using any special libraries (Python)

In this post, I’ll share a real example (and an application that you can download and use for your personal use) on how to turn text into fun representation such as: flipped, reversed, substituted with other characters using Python. The output is not an image, but still real text that are not easily accessible from the keyboard but they are part of the character set in your operating system.

There are many creative ways people have come up with text transformation especially over the Internet when native text transformation feature doesn’t exist. Leetspeak, phoneword, hexspeak, emoticon, calculator spellings, USD Encoding are just some of the popular methods.

A conversion table can be used to transform lowercase, uppercase, numeric and punctuation or symbols characters from keyboard to turn a normal input to something funky looking, more interesting, and even twisted.

For this application, as a bonus, I also incorporate a clipboard functionality to copy the transformed text to the clipboard from where you can paste the transformed text in your social media posts/updates or any editor.

The idea is to turn a normal text input into inverted, flipped text: horizontally and vertically. And the cool part is, because the output is also text, you can continue to edit the transformed, funky text just like normal text.

Fig 1. Snapshot of the application

The image in Fig 1 shows the original text typed in the top box (letters, numbers, and punctuations), and the bottom box shows the transformed text…still readable, but appears in a funky way, making it more interesting.

Fig 2. Transforming an already transformed text

Fig 2 shows that after a transformed text, we can copy that text from the bottom box (select all, then ctrl-c) and paste it into the top box (ctrl-v), and click Transform to get a reversed, refection effect!

The text from both the top and bottom box can be copied and pasted as text in either boxes using standard ctrl-c (on Windows) and ctrl-v (on Windows). There’s an image button with a copy icon below “Transform” button that copies the transformed text (from bottom box) and puts it in the clipboard….so that you can now paste the new, funky text into a social media page, notepad, Word document, web page, etc.

Here’s the high-level process of my implementation of mirroring and inverting = flipping horizontally + vertically:

  1. Enter text.
  2. String reverse the entered text.
  3. Split the string into individual characters.
  4. Then look for associated flipped character codes from a conversion array (using a dictionary object), and create a new array of characters with the converted characters.
  5. Rebuild the array into a contiguous string.
  6. Output the string in a way that can be easily copied to clipboard.

To implement step #4, I created my own dictionary object that looks something like below:

charmappings ={


and so on…for all supported characters and their associated unicodes. Then we can get a Value using a Key with a statement such as: c = charmappings.get(k) [where c is a transformed character of the input character k]

The “More Demos!” button opens your web browser and navigates to my blog site showing posts related to Python…so you can read about other cool stuffs you can do.

The clipboard functionality is implemented by using pyperclip library of Python. The general UI is implemented with tkinter library. No special text library is used for the transformation.

Best way to understand it is by using the app itself, which is downloable here as a ZIP file. Once the ZIP is downloaded, extract its contents (just one file: textransformaton.exe) somewhere (such as Desktop) and double-click it to run it.

Indeed, there are mobile apps in Playstore and Apple Store that offer this feature as paid or in-app purchases or free-with-ads. Now you have a tool in your hands to run it from PC and post it anywhere for free including in your email, text, or mobile apps.

(: ʇᴉ ɥʇᴉʍ unɟ pɐɥ puɐ—ʇsod sᴉɥʇ pǝʎoɾuǝ noʎ ǝdoH

Interested in creating programmable, cool electronic gadgets? Give my newest book on Arduino a try: Hello Arduino!

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top