# HG changeset patch # User HackBot # Date 1500641335 0 # Node ID a40e8e968f756262501d4726391fab329fb80441 # Parent 0aef5f39601f34ba819a55c54f4da7123b40ecb9 ` sed -i \'s/\\r//\' bin/rot13_stdin diff -r 0aef5f39601f -r a40e8e968f75 bin/rot13_stdin --- a/bin/rot13_stdin Fri Jul 21 12:38:28 2017 +0000 +++ b/bin/rot13_stdin Fri Jul 21 12:48:55 2017 +0000 @@ -1,29 +1,29 @@ -#!/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')) +#!/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')) +