翁学天 (Xuetian Weng ),即CS Slayer写了scel2org,是fcitx-tools的一部分。
我把他的.c程序挪了出来,不用装别的,gcc scel2org.c即可编译:
〔这里〕可下载 scel2org.c utarray.h uthash.h utils.h
然后搞了个Python版(29行)
import sys f = open(sys.argv[1], 'rb')if f.read(12) != b'\x40\x15\0\0\x44\x43\x53\x01\x01\0\0\0': raise ValueError() f.seek(0x1540) if f.read(4) != b'\x9d\x01\0\0': raise ValueError()all_py = [] to_uint16 = lambda bs: int.from_bytes(bs, byteorder='little', signed=False) dec_utf16 = lambda bs: bs.decode('utf-16')while True:f.read(2)pinyin = dec_utf16(f.read(to_uint16(f.read(2))))all_py.append(pinyin)if pinyin == "zuo": breakwhile True:bs = f.read(2)if len(bs) == 0: breaksymcnt = to_uint16(bs)cnt = to_uint16(f.read(2))bs = f.read(cnt)pyidx = [to_uint16(bs[i:i+2]) for i in range(0, len(bs), 2)]for i in range(symcnt):b = f.read(to_uint16(f.read(2)))print(dec_utf16(b), ' '.join([all_py[i] for i in pyidx]))f.read(to_uint16(f.read(2)))
Python很方便,fread改f.read :-)
翁学天很强,他现在是fcitx的主要开发者。
小企鹅输入法(Fcitx)最初是由Yuking开发的,最初名为gWuBi,自1.7版改名为Fcitx,基于XIM协议,为Linux在中国的普及做出了重要贡献。
Fcitx: Flexible Input Method Framework 〔详情〕