1 #! /usr/bin/env python3
2 "Recode to default charset"
5 from getopt import getopt
6 from m_lib.defenc import default_encoding
8 from_charset = "cp1251"
9 to_charset = default_encoding
11 options, arguments = getopt(sys.argv[1:], 'f:t:')
12 for option, value in options:
18 output = getattr(sys.stdout, 'buffer', sys.stdout)
22 for file in arguments:
23 with open(file, 'rb') as infile:
26 line.decode(from_charset, "replace").
27 encode(to_charset, "replace"))
29 input = getattr(sys.stdin, 'buffer', sys.stdin)
32 line.decode(from_charset, "replace").encode(to_charset, "replace"))