jp_text_parsing/kana_assc.py

28 lines
795 B
Python

import mmap
import struct
from pathlib import Path
kana1_data = Path("YGO_2020/CARD_Kana1_J.bin").read_bytes()
kana2_data = Path("YGO_2020/CARD_Kana2_J.bin").read_bytes()
kana3_data = Path("YGO_2020/CARD_Kana3_J.bin").read_bytes()
## The offsets pulled from the file
items1 = [x[0] for x in struct.iter_unpack("<I", kana1_data)]
#print(f"Foo {[f'0x{x:x}' for x in offsets[2:4]]}") # Getting range and convert to hex
#print(", ".join("{:04x}".format(x) for x in items1[6:8]))
print(", ".join("{:04x}".format(x) for x in kana1_data[6:8]))
kana1_data[6:8].decode("utf-16le", errors="replace")
print()
# kana1_data[2:4].decode("utf-16le", errors="replace")
# 'い'
# kana2_data[2:4].decode("utf-16le", errors="replace")
# 'ん'
# kana3_data[2:4].decode("utf-16le", errors="replace")
# 'せ'