Check for dupes in msx2utf8, to avoid last commit's bug

This commit is contained in:
Andy Teijelo Pérez 2016-09-15 14:35:32 -04:00
parent d8cce15786
commit bce616eaf0

View file

@ -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':