scripts/misc/mimedecode
2022-04-13 13:08:34 +02:00

14 lines
290 B
Python
Executable file

#!/usr/bin/env python3
from email.header import decode_header
import sys
if len(sys.argv) < 2:
encoded = sys.stdin.read()
else:
encoded = ' '.join(sys.argv[1:])
text, encoding = decode_header(encoded)[0]
if type(text) is str:
print(text)
else:
print(text.decode(encoding))