Skip to content

Instantly share code, notes, and snippets.

@lotem
Created July 1, 2012 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lotem/3027342 to your computer and use it in GitHub Desktop.
Save lotem/3027342 to your computer and use it in GitHub Desktop.
倉頡碼表標註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
Copy link

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

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