PHP Code:
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import sys
__usage__='''
upsidedown.py "The quick brown fox jumps over the lazy dog."
˙ƃop ʎzɐʅ ɘɥʇ ɹɘʌo sdɯuɾ xoɟ uʍoɹq ʞɔıuq ɘɥﻠ
'''
rot180={
'a' : u'\u0250', # ɐ
'b' : u'q',
'c' : u'\u0254', # ɔ
'd' : u'p',
'e' : u'\u0258', # ǝ
'f' : u'\u025F', # ɟ
'g' : u'\u0183', # ƃ
'h' : u'\u0265', # ɥ
'i' : u'\u0131', # ı
'j' : u'\u027E', # ɾ
'k' : u'\u029E', # ʞ
'l' : u'\u0285', # ʅ
'm' : u'\u026F', # ɯ
'n' : u'u', # u
'p' : u'd',
'r' : u'\u0279', # ɹ
't' : u'\u0287', # ʇ
'u' : u'n',
'v' : u'\u028C', # ʌ
'w' : u'\u028D', # ʍ
'y' : u'\u028E', # ʎ
'.' : u'\u02D9', # ˙
'[' : u']',
'(' : u')',
'{' : u'}',
'?' : u'\u00BF', # ¿
'!' : u'\u00A1', # ¡
"\'" : u',',
'<' : u'>',
'_' : u'\u203E', # ‾
'"' : u'\u201E', # „
'\\' : u'\\',
';' : u'\u061B', # ؛
'\u203F' : u'\u2040', # ‿ --> ⁀
'\u2045' : u'\u2046', # ⁅ --> ⁆
'\u2234' : u'\u2235', # ∴ --> ∵
# 'A':u'\u15CA', # ᗊ (viewable in emacs, but not in terminal)
# 'B':u'\u15FA', # ᗺ (viewable in emacs, but not in terminal)
'C':u'\u0186', # Ɔ (viewable in emacs, but not in terminal)
# 'D':u'\u15ED', # ᗭ (viewable in emacs, but not in terminal)
'E':u'\u2203', # ∃ (viewable in emacs, but not in terminal)
# 'N':u'\u2d4d', # ⵍ (viewable in terminal, but not in emacs)
# 'O':u'\u0B20', # ଠ (viewable in emacs, but not in terminal)
# 'R':u'\u1588', # ᖈ (viewable in emacs, but not in terminal)
'T':u'\uFEE0', # ﻠ
'U':u'\u041F', # П
'V':u'\u039B', # Λ
# 'V':u'\u2d37', # ⴷ (viewable in terminal, but not in emacs)
# 'Y':u'\u2d43', # ⵃ (viewable in terminal, but not in emacs)
# '2':u'\u2D52', # ⵒ (viewable in terminal, but not in emacs)
# '3':u'\u15F4', # ᗴ (viewable in emacs, but not in terminal)
}
input_str=sys.argv[1]
print(''.join(reversed([rot180.get(achr,achr) for achr in input_str])))
If anyone can explain why certain unicode characters are viewable in emacs, but not from a gnome-terminal, and vice versa, I'd really like to know. (See the commented-out source code for examples.)
Bookmarks