# # qkantab - a tool to create a current/old kanji table. # # % ruby qkantab.rb wxqkanji.sed | column | expand | nkf -sc > qkantab.txt # # Copyright (C) 2004 Satoru Takabayashi # All rights reserved. # This is free software with ABSOLUTELY NO WARRANTY. # # You can redistribute it and/or modify it under the terms of # the GNU General Public License version 2. $KCODE = "e" require 'kconv' def add (table, c, q) table[c] = [] if table[c].nil? table[c].push(q) end table = Hash.new while line = gets line = line.toeuc if m = %r!^y/(.*)/(.*)/!.match(line) ckanji = m[1].split('') qkanji = m[2].split('') ckanji.each_with_index {|c, i| add(table, c, qkanji[i]) } elsif /^# 以下のルーチンは/.match(line) break elsif subst = line.scan(%r!s/(.*?)/(.*?)/g!) subst.each {|c, q| add(table, c, q) } end end table.keys.sort.map {|key| printf("%s %s\n", key, table[key].join('')) }