# HG changeset patch # User HackBot # Date 1500640570 0 # Node ID 8f3c7e3a6f51931450f156f119266486990c14d6 # Parent 5f2902c0470dfbfc180abe17531710a835d33ddd ` mv MXOA bin/rot13 && chmod +x bin/rot13 diff -r 5f2902c0470d -r 8f3c7e3a6f51 MXOA --- a/MXOA Fri Jul 21 12:34:55 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -#!/usr/bin/env python - -import re, sys, unicodedata as U -def tr(c): - m = re.match(r'(.*\bLATIN\b.*\bLETTER )([A-Z])\b(.*)', U.name(c, '')) - if m: - p, q, r = m.groups() - n = ord(q) - ord('A') - try: - return U.lookup(p + chr(ord('A') + (n + 13) % 26) + r) - except KeyError: - return c - return c - -def tr2(c): - d = tr(c) - if d != c: - return d - else: - cs = [unichr(int(x, 16)) for x in U.decomposition(c).split()] - ds = [tr(x) for x in cs] - if cs != ds: - return u''.join(ds) - else: - return c - -for c in unicode(sys.stdin.read(), 'utf8'): - sys.stdout.write(tr2(c).encode('utf8')) - diff -r 5f2902c0470d -r 8f3c7e3a6f51 bin/rot13 --- a/bin/rot13 Fri Jul 21 12:34:55 2017 +0000 +++ b/bin/rot13 Fri Jul 21 12:36:10 2017 +0000 @@ -1,1 +1,29 @@ -print_args_or_input "$@" | tr a-zA-Z n-za-mN-ZA-M +#!/usr/bin/env python + +import re, sys, unicodedata as U +def tr(c): + m = re.match(r'(.*\bLATIN\b.*\bLETTER )([A-Z])\b(.*)', U.name(c, '')) + if m: + p, q, r = m.groups() + n = ord(q) - ord('A') + try: + return U.lookup(p + chr(ord('A') + (n + 13) % 26) + r) + except KeyError: + return c + return c + +def tr2(c): + d = tr(c) + if d != c: + return d + else: + cs = [unichr(int(x, 16)) for x in U.decomposition(c).split()] + ds = [tr(x) for x in cs] + if cs != ds: + return u''.join(ds) + else: + return c + +for c in unicode(sys.stdin.read(), 'utf8'): + sys.stdout.write(tr2(c).encode('utf8')) +