summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/prettytok/prettytok-decode-8bit.py
blob: 231cf84bd97b1fb995407270895b8f8ab968f3f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/python3
"""
A hack to allow decoding for example ^^[ to the proper escape sequence.
"""

import sys
import re
def replace_8bit(match_: re.Match) -> str:
	return chr(ord(match_.group(1))^0x40)
if __name__ == '__main__':
	for line in sys.stdin:
		sys.stdout.write(re.sub(r"\^\^(.)", replace_8bit, line))