Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
screxport as a cli tool for text extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
kamikat committed May 12, 2013
1 parent da49cfb commit 54c7914
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions screxport.py
@@ -1,10 +1,14 @@
#!/usr/bin/env python

import struct
import argparse

parser = argparse.ArgumentParser(description='Scan file to find shift-jis string')
parser.add_argument('input', help='scenario file')
args = parser.parse_args()

data = open('scr.bin', 'rb').read()
import struct

output = open('scr.utf8.txt', 'w')
data = open(args.input, 'rb').read()

length = len(data)

Expand All @@ -14,6 +18,8 @@
continue
if val > length:
continue
if val % 2 != 0:
continue
if data[i+val-2:i+val] != '\x00\x00':
continue
try:
Expand All @@ -22,9 +28,8 @@
if char < "\x1f":
strline = ""
if len(strline) > 0:
print >>output, "0x%010X-0x%010X(0x%04X)\t%s\r" % \
print "0x%010X-0x%010X(0x%04X)\t%s\r" % \
(i, i + val, val, strline.encode('utf-8'))
except:
continue

output.close()

0 comments on commit 54c7914

Please sign in to comment.