/* Unicode異体字(Ideographic Variation Sequence)拡張モジュール 使いかた: 実行するとSKKGateのゲート2拡張モジュールとして常駐する。(メッセージは一切出ない) 初回起動時は異体字辞書をカレントディレクトリに自動的にダウンロードする。 あとは「v9089」「邉」等で変換が可能となる。 もう一度実行すると終了する。 「IPAmj明朝フォント」等をインストールしすべてのフォントの設定変更が必要。 一般的なフォントのままでは無意味なので注意。 β0+11i対応版 てかβ9i以降は辞書ファイルに加工して追加すべき */ URL = "http://www.unicode.org/ivd/data/2012-03-02/IVD_Sequences.txt" FILE = "IVD_Sequences.txt" myself = 2 ///< 自分のゲート番号 (ゲート2: 拡張モジュール) dict = {} ///< 辞書格納用 W = WScript G = new ActiveXObject("SKKGate") S = new ActiveXObject("WScript.Shell") F = new ActiveXObject("Scripting.FileSystemObject") F.FileExists(FILE) || download(URL, FILE) init(load(FILE)) /// ダウンロード function download(u, p) { var h = W.CreateObject("MSXML2.XMLHTTP"), s = 1 try { h.Open("GET", u, 0) h.Send() s = h.status } catch (e) {} if (s != 200) return s with (W.CreateObject("ADODB.Stream")) { Type = 1 Open() Write(h.responseBody) SaveToFile(p, 2) } return 0 } /// ロード function load(f) { var a, t with (W.CreateObject("ADODB.Stream")) { Type = 2 Charset = "iso-8859-1" Open() LoadFromFile(f) t = ReadText(2) Close() Charset = t == "\xFF\xFE" ? "utf-16" : "_autodetect" Open() LoadFromFile(f) a = ReadText(-1).split(/\r|\n|\r\n/) Close() } return a } /// 文字 function ch(x) { var c = parseInt(x, 16), f = String.fromCharCode return c >> 16 ? f((c >> 10) + 55232) + f(c & 1023 | 56320) : f(c) } /// 学習 function put(i, c) { if (!(i in dict)) dict[i] = [] dict[i].push(c) } /// 検索 function search(i) { return (i in dict) ? dict[i].join('\3') : "" } /// 辞書構築 function init(a) { var l, x, c for (l in a) { if (a[l].charAt(0) == "#") continue x = a[l].split(";")[0].split(" ") c = ch(x[0]) + ch(x[1]) + "\2" + a[l] put(x[0].toLowerCase(), c) put(ch(x[0]), c) } } // メイン for (;;) { // 待機 id = G.Sync(myself) // 終了 (停止要求 -1 / 二重起動 -2) if (id < 0) { if (id == -2) { S.Popup("停止します") G.Sync(-1, myself) } break } index = G.Get() attr = G.Get(2) switch (id) { // 変換 case 0: if (attr >= 8) break // 特殊変換を除外 t = index.replace(/^[UVX]\+?/i, "").toLowerCase() result = search(t).split(/\3|$/) for (i in result) G.Put(result[i]) break } }