Check for dupes in msx2utf8, to avoid last commit's bug
This commit is contained in:
parent
d8cce15786
commit
bce616eaf0
1 changed files with 10 additions and 3 deletions
13
msx2utf8.py
13
msx2utf8.py
|
@ -27,10 +27,17 @@ def msxchars():
|
|||
for i in range(65,96):
|
||||
yield (256 + i, chars[160 + i])
|
||||
|
||||
charmap = {}
|
||||
msx2uni = {}
|
||||
uni2msx = {}
|
||||
|
||||
for m,c in msxchars():
|
||||
charmap[m] = c
|
||||
if m in msx2uni:
|
||||
raise ValueError("MSX code {} is duplicated".format(m))
|
||||
msx2uni[m] = c
|
||||
if c in uni2msx:
|
||||
raise ValueError("Codepoint {} ({}) is duplicated"
|
||||
.format(ord(c), c))
|
||||
uni2msx[c] = m
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
while True:
|
||||
|
@ -44,7 +51,7 @@ if len(sys.argv) < 2:
|
|||
sys.stdout.write('\x01')
|
||||
break
|
||||
code = 256 + c[0]
|
||||
char = charmap[code]
|
||||
char = msx2uni[code]
|
||||
sys.stdout.write(char)
|
||||
|
||||
if sys.argv[1] == '-l':
|
||||
|
|
Loading…
Reference in a new issue