5172
|
1 |
#!/usr/bin/env python
|
|
2 |
import sys
|
|
3 |
import string
|
|
4 |
|
|
5 |
if len( sys.argv ) == 1 :
|
|
6 |
for asc_line in sys.stdin.readlines():
|
|
7 |
mpw_line = string.replace(asc_line, "\\xA5", "\245")
|
|
8 |
mpw_line = string.replace(mpw_line, "\\xB6", "\266")
|
|
9 |
mpw_line = string.replace(mpw_line, "\\xC4", "\304")
|
|
10 |
mpw_line = string.replace(mpw_line, "\\xC5", "\305")
|
|
11 |
mpw_line = string.replace(mpw_line, "\\xFF", "\377")
|
|
12 |
mpw_line = string.replace(mpw_line, "\n", "\r")
|
|
13 |
mpw_line = string.replace(mpw_line, "\\n", "\n")
|
|
14 |
sys.stdout.write(mpw_line)
|
|
15 |
elif sys.argv[1] == "-r" :
|
|
16 |
for mpw_line in sys.stdin.readlines():
|
|
17 |
asc_line = string.replace(mpw_line, "\n", "\\n")
|
|
18 |
asc_line = string.replace(asc_line, "\r", "\n")
|
|
19 |
asc_line = string.replace(asc_line, "\245", "\\xA5")
|
|
20 |
asc_line = string.replace(asc_line, "\266", "\\xB6")
|
|
21 |
asc_line = string.replace(asc_line, "\304", "\\xC4")
|
|
22 |
asc_line = string.replace(asc_line, "\305", "\\xC5")
|
|
23 |
asc_line = string.replace(asc_line, "\377", "\\xFF")
|
|
24 |
sys.stdout.write(asc_line)
|