Skip to content

Instantly share code, notes, and snippets.

@taotao54321
Created December 14, 2017 12:40
Show Gist options
  • Save taotao54321/539af02aedab5bef2dc8ae9e18bb2789 to your computer and use it in GitHub Desktop.
Save taotao54321/539af02aedab5bef2dc8ae9e18bb2789 to your computer and use it in GitHub Desktop.
Helps to create .tbl files
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Helps to create .tbl files
Write "game.in":
0x30
あいうえお
かきくけこ
...
Run:
$ tblhelper game.in
Output:
30=あ
31=い
32=う
...
"""
import fileinput
def chomp(s):
return s.rstrip("\r\n")
def main():
code = None
for line in map(chomp, fileinput.input()):
if fileinput.isfirstline():
code = int(line, base=0)
continue
for c in line:
print(f"{code:02X}={c}")
code += 1
if __name__ == "__main__": main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment