Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
倉頡碼表標註Ext-A/B/C/D
#!/usr/bin/env python
import sys
for x in sys.stdin:
t = x.rstrip().split("\t")
if len(t) != 2:
print x,
continue
ch = t[0].decode('utf8')
if len(ch) != 1:
print "ERROR: %s" % x,
break
code = ord(ch)
ext = ''
if code >= 0x3400 and code <= 0x4DBF:
ext = '{A}'
elif code >= 0x20000 and code <= 0x2A6DF:
ext = '{B}'
elif code >= 0x2A700 and code <= 0x2B73F:
ext = '{C}'
elif code >= 0x2B740 and code <= 0x2B81F:
ext = '{D}'
print t[0] + "\t" + ext + t[1]
@LEOYoon-Tsaw

This comment has been minimized.

Copy link

@LEOYoon-Tsaw LEOYoon-Tsaw commented May 19, 2013

這個要把字典文件名命名爲sys,放在同一文件夾下執行嗎?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment