-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
|
||
strings = {} | ||
|
||
for path in sys.argv[1:]: | ||
with open(path, 'rb') as in_file: | ||
data = in_file.read() | ||
|
||
identifiers = [ | ||
b"/LANGID", | ||
b"/CREDITS_H_", | ||
b"/MONDOTEXT_H_", | ||
b"/SCREENTEXT_" | ||
] | ||
|
||
for identifier in identifiers: | ||
cursor = 0 | ||
while True: | ||
start = data.find(identifier, cursor) | ||
if start == -1: | ||
break | ||
sep = data.find(b"/", start + 1) | ||
assert(sep > start) | ||
end = data.find(b"\0", sep + 1) | ||
assert(end > sep) | ||
|
||
key = data[start + 1:sep] | ||
value = data[sep + 1:end] | ||
|
||
tmp = value.decode('windows-1252') | ||
tmp = tmp.translate(str.maketrans({"\n": r"\n", | ||
"\t": r"\t", | ||
"\r": r"\r", | ||
"\"": r"\"", | ||
"\\": r"\\"})) | ||
value = tmp.encode('windows-1252') | ||
|
||
if key in strings: | ||
print("Warning: duplicate key " + str(key), file=sys.stderr) | ||
strings[key] = value | ||
|
||
cursor = end + 1 | ||
|
||
for key in strings: | ||
value = strings[key].decode('windows-1252') | ||
key = key.decode('ascii') | ||
print(key + "\t" + value + "\r\n", end='', flush=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
|
||
strings = {} | ||
|
||
for path in sys.argv[1:]: | ||
with open(path, 'rb') as in_file: | ||
data = in_file.read() | ||
|
||
# FIXME: Make sure first 4 bytes are not 'ENCR' or decrypt file | ||
|
||
cursor = 0 | ||
while(cursor < len(data)): | ||
start = cursor | ||
|
||
# Find end of this entry | ||
while(cursor < len(data)): | ||
if (data[cursor] == 10 or data[cursor] == 13): | ||
break | ||
cursor += 1 | ||
end = cursor | ||
|
||
sep = data.find(9, start) | ||
key = data[start:sep] | ||
value = data[sep + 1:end] | ||
if key in strings: | ||
print("Warning: duplicate key " + str(key), file=sys.stderr) | ||
strings[key] = value | ||
|
||
# Move to next entry | ||
while(cursor < len(data)): | ||
if (data[cursor] != 10 and data[cursor] != 13): | ||
break | ||
cursor += 1 | ||
|
||
for key in strings: | ||
value = strings[key].decode('windows-1252') | ||
key = key.decode('ascii') | ||
print("'" + key + "' -> '" + value + "'") |