Americas

  • United States
sandra_henrystocker
Unix Dweeb

Text for Linux users who just happen to be standing on their heads

How-To
May 31, 20163 mins
Data CenterLinux

Here’s one more really odd thing that you might consider doing when you’re finished setting up your 100+ new servers and troubleshooting problems that have stumped all the techies in the nearby vicinity – displaying text messages upside down. And if sheer entertainment is not enough of a reason, consider that the exercise might motivate you to think more deeply about the mysterious nature of character encoding systems. Yes, we’re going to turn phrases upside down — not by flipping our monitors — but by exchanging the usual characters that we see with their closest upside down equivalents – and then by presenting them on the screen in the reverse order.

First, an example of what you might see:

$ echo Hello, World! | ./flipme
¡p|ɹoʍ 'o||ǝɥ
$ echo hello there|flipme
ǝɹǝɥʇ o||ǝɥ
$ echo What on earth is that? | ./flipme
¿ʇɐɥʇ sı ɥʇɹɐǝ uo ʇɐɥʍ

Intrigued? Let’s take a look into what’s required to pull this off. First, that flipme reference that you see in the examples above is a Perl script that I found at this URL thanks to a reader who pointed me to it.

https://pastebin.com/k06AdyUa

What it does is replace the characters in whatever string you provide with their “flipped” counterparts. Some of the characters are relatively easy. The letters n and u, for example, are already 180 degree siblings and some characters, like 0, don’t look any different if you flip them.

The characters are rotated, not mirror images of each other. The difference between mirror images and 180 degree rotations is illustrated in the figures below.

mirror vs rotate

The flipme script uses the characters in the normal character set that look like 180 degree rotations of other characters or it uses other characters in the utf8 character set that are close to the 180 degree rotations. The letters “d” and “p”, like “n” and “u” are naturals. The letter “e”, on the other hand, takes a little more effort. What we find is what I call a “schwa” (from many years ago as a speech therapist). A schwa is an unstressed vowel and is written as a rotated “e”.

"d" => "p",
"e" => "x{01DD}",

Why does the utf8 character set include rotated letters? Well, technically it doesn’t. It includes a variety of international characters set and quite a number of them just happen to look like the Latin alphabet that have been rotated. Check out this page for a nice listing:

https://www.upsidedowntext.com/unicode

The script sets up a table to facilitate the conversions with entries such as these:

"P" => "x{0500}",
"Q" => "x{038C}",

It then flips the string that’s sent to it and then replaces each letter in the string with its rotated counterpart.

$ echo "I'm feeling a little dizzy. Think I need to go home now." | ./flipme
˙ʍou ǝɯoɥ oƃ oʇ pǝǝu ı ʞuıɥ⊥ ˙ʎzzıp ǝ|ʇʇı| ɐ ƃuı|ǝǝɟ ɯ,ı

As you’ll note, some of the “flipped” characters only approximate a 180 degree rotation of the originals. And some look really good except for their placement which often makes them appear to float a little higher above the line than they should. The image below illustrates that the flipped characters are readable, though not precise rotations.

flipping

Of course, given adequate demand by Unix admins who want to work standing on their heads, someone would probably come up with a character set that flips letters even better. Until then, scripts like flipme will probably entertain us well enough.

sandra_henrystocker
Unix Dweeb

Sandra Henry-Stocker has been administering Unix systems for more than 30 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she's chasing the bears away from her bird feeders.

The opinions expressed in this blog are those of Sandra Henry-Stocker and do not necessarily represent those of IDG Communications, Inc., its parent, subsidiary or affiliated companies.

More from this author