{"id":19895,"date":"2023-07-05T12:06:20","date_gmt":"2023-07-05T19:06:20","guid":{"rendered":"https:\/\/www.kith.org\/jed\/?page_id=19895"},"modified":"2025-09-20T23:42:08","modified_gmt":"2025-09-21T06:42:08","slug":"turning-text-upside-down","status":"publish","type":"page","link":"https:\/\/www.kith.org\/jed\/hodgepodge\/code\/turning-text-upside-down\/","title":{"rendered":"Turning text upside-down"},"content":{"rendered":"\r\n<p>I wrote this code in 1995. For an update from 2018, including a link to a much better online tool for creating upside-down-looking text, see my Words & Stuff column <a href=\"https:\/\/www.kith.org\/words\/2018\/01\/28\/xxxn%C9%90%C9%9F\/\">XXX: u\u028dop-\u01ddp\u0131sdn<\/a>.<\/p>\r\n\r\n<hr width=\"25%\" \/>\r\n\r\n<pre style=\"overflow-x: auto;\">\r\n#!\/usr\/sbin\/perl\r\n\r\n# umop.pl: Program to turn a string upside-down.\r\n#\r\n# Version 1.0, copyright 1995 by Jed Hartman.\r\n# Last modification: 16 August 1995.\r\n#\r\n# Based on my earlier umop.c.  The perl version is much shorter!\r\n#\r\n# Permission to use, copy, modify, and distribute this software and its\r\n# documentation, in whole or in part, for any purpose and without fee is\r\n# hereby granted, provided that: (a) the above copyright notice appear in\r\n# all copies; (b) both the copyright notice and this permission notice\r\n# appear in supporting documentation; and (c) no fee is charged for further\r\n# redistribution of the software.  This software is provided \"as is\" without\r\n# express or implied warranty.\r\n#\r\n# Thanks to Jef Poskanzer for the permission-to-use notice.\r\n#\r\n#\r\n# Notes:\r\n#\r\n# Reads standard input or a list of files on the command line; writes to\r\n# standard output.  Any character which cannot be reasonably inverted is\r\n# left alone; many uppercase characters are converted to lowercase.\r\n# Inversions look better in some typefaces than in others.  To change the\r\n# inversion mapping, edit the two strings in the line containing the \"tr\"\r\n# command.\r\n#\r\n# Width-to-justify-in defaults to 78 columns.  If you want to specify some\r\n# other width, use -w width on the command line.\r\n#\r\n# If by some chance you don't have access to the getopt.pl command-line-\r\n# option-handling library, just comment out everything before the first\r\n# \"while\" line below, except the \"$width = 78\" line.\r\n#\r\n# Arguably, umop should re-wrap the inverted text to the specified number of\r\n# columns, rather than just attempting to justify each line in that number\r\n# of columns.  But that's a project for another day.\r\n#\r\n# If you have comments or suggestions, write to me at logos@kith.org.  I'm a\r\n# novice perl hacker and would be delighted to receive style comments.\r\n\r\n\r\n# Get command-line option(s):\r\n\r\nrequire \"getopt.pl\";\r\n\r\n&Getopt('w');\r\n\r\n\r\n# Set justification width according to command line:\r\n\r\nif ($opt_w && $opt_w != 1)\r\n{\r\n  $width = $opt_w;\r\n}\r\nelse\r\n{\r\n  $width = 78;\r\n}\r\n\r\n\r\n# For each line of input, replace every character with a character that\r\n# looks like it upside-down.  Then reverse the order of the characters on\r\n# the line.\r\n\r\nwhile ($a[$i] = <>)\r\n{\r\n  chop ($a[$i]);\r\n  $a[$i] =~ tr\/A-Za-z,`'()[]><!2345679^\/Vq>p3j6HIrK7WNOdbJS+nAMXhZeq>paj6y!fklwuodbJs+n^mxhz`,,)(][<>i5Eh29L6v\/;\r\n  $a[$i] = reverse $a[$i];\r\n  $i++;\r\n}\r\n\r\n\r\n# Reverse the order of the lines, and print them right-justified.\r\n\r\n@a = reverse @a;\r\n\r\nforeach (@a)\r\n{\r\n  printf \"%${width}s\\n\",$_;\r\n}\r\n\r\n\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":5,"featured_media":0,"parent":5479,"menu_order":60,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-19895","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/pages\/19895","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/comments?post=19895"}],"version-history":[{"count":5,"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/pages\/19895\/revisions"}],"predecessor-version":[{"id":20665,"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/pages\/19895\/revisions\/20665"}],"up":[{"embeddable":true,"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/pages\/5479"}],"wp:attachment":[{"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/media?parent=19895"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}