3 (defun decode-url-string (string &optional coding-system)
4 (if (> (length string) 0)
7 (while (string-match "%\\([0-9A-F][0-9A-F]\\)" string i)
8 (setq dest (concat dest
9 (substring string i (match-beginning 0))
12 (string-to-int (match-string 1 string) 16))))
15 (concat dest (substring string i))
18 (defconst www-ids-find-version "0.22.3")
20 (defvar www-ids-find-ideographic-products-file-name
21 (expand-file-name "ideographic-products"
26 chise-system-db-directory))))
28 (defvar www-ids-find-tang-chars-file-name
29 "~tomo/projects/chise/ids/www/tang-chars.udd")
31 (defun www-ids-find-format-line (c is)
32 (let ((str (encode-coding-string (format "%c" c) 'utf-8-er))
37 ((string-match "&CB\\([0-9]+\\);" str)
38 (setq code (string-to-int (match-string 1 str)))
39 (insert "<a href=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/char-desc?char=")
41 (insert (format "\"><img alt=\"CB%05d\" src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/cb-gaiji/%02d/CB%05d.gif\">\n"
42 code (/ code 1000) code))
43 (insert (format "CB%05d</a>" code))
45 ((string-match "&JC3-\\([0-9A-F]+\\);" str)
46 (setq code (string-to-int (match-string 1 str) 16))
47 (insert "<a href=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/char-desc?char=")
49 (insert (format "\"><img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">\n"
51 (insert (format "JC3-%04X</a>" code))
53 ((string-match "&J\\(78\\|83\\|90\\|SP\\)-\\([0-9A-F]+\\);" str)
54 (setq plane (match-string 1 str)
55 code (string-to-int (match-string 2 str) 16))
56 (insert "<a href=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/char-desc?char=")
58 (insert (format "\"><img alt=\"J%s-%04X\" src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/JIS-%s/%02d-%02d.gif\">\n"
61 (- (logand code 255) 32)))
62 (insert (format "J%s-%04X</a>" plane code))
64 ((string-match "&G\\([01]\\)-\\([0-9A-F]+\\);" str)
65 (setq plane (string-to-int (match-string 1 str))
66 code (string-to-int (match-string 2 str) 16))
67 (insert "<a href=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/char-desc?char=")
69 (insert (format "\"><img alt=\"G%d-%04X\" src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/GB%d/%02d-%02d.gif\">\n"
72 (- (logand code 255) 32)))
73 (insert (format "G%d-%04X</a>" plane code))
75 ((string-match "&C\\([1-7]\\)-\\([0-9A-F]+\\);" str)
76 (setq plane (string-to-int (match-string 1 str))
77 code (string-to-int (match-string 2 str) 16))
78 (insert "<a href=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/char-desc?char=")
80 (insert (format "\"><img alt=\"C%d-%04X\" src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/CNS%d/%04X.gif\">\n"
81 plane code plane code))
82 (insert (format "C%d-%04X</a>" plane code))
84 ((string-match "&ZOB-\\([0-9]+\\);" str)
85 (setq code (string-to-int (match-string 1 str)))
86 (insert "<a href=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/char-desc?char=")
88 (insert (format "\"><img alt=\"ZOB-%04d\" src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/ZOB-1968/%04d.png\">\n"
90 (insert (format "ZOB-%04d</a>" code))
93 (insert "<a href=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/char-desc?char=")
96 (mapconcat (lambda (c)
97 (if (<= (char-int c) #x7F)
105 (goto-char (point-min))
106 (while (search-forward "&" nil t)
107 (replace-match "&" t 'literal))
111 (or (if (setq ucs (or (char-ucs c)
112 (encode-char c 'ucs)))
114 " <a href=\"http://www.unicode.org/cgi-bin/GetUnihanData.pl?codepoint=%X\">%s</a>"
116 (cond ((<= ucs #xFFFF)
117 (format "U+%04X" ucs))
119 (format "U-%08X" ucs))))
123 (format " <a href=\"http://geta.mag.keio.ac.jp/chiseperl/map.cgi?code=%X\">(link map)</a>"
130 (encode-coding-string
131 (ideographic-structure-to-ids is)
133 (goto-char (point-min))
134 (while (re-search-forward "&CB\\([0-9]+\\);" nil t)
135 (setq code (string-to-int (match-string 1)))
137 (format "<img alt=\"CB%05d\" src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/cb-gaiji/%02d/CB%05d.gif\">"
138 code (/ code 1000) code)
144 www-ids-find-tang-chars-file-name)
145 (goto-char (point-min))
146 (re-search-forward (format "^%d$" ucs) nil t)))
148 (format " <a href=\"http://coe21.zinbun.kyoto-u.ac.jp/djvuchar?query=%s\">"
151 (format "%%%02X" (char-int c)))
152 (encode-coding-string (char-to-string c)
155 (princ (encode-coding-string "
\e$B"M
\e(B[
\e$BEbBeBsK\
\e(B]</a>" 'utf-8-jp-er)))
158 (defun www-ids-insert-chars-including-components (components
159 &optional ignored-chars)
160 (let ((products (copy-list (ideographic-products-find components)))
163 ((> (length products) 10000)
165 ((> (length products) 4096)
168 (< (char-int a)(char-int b))))
170 ((> (length products) 512)
173 (if (setq as (char-total-strokes a))
174 (if (setq bs (char-total-strokes b))
176 (< (char-int a)(char-int b))
179 (< (char-int a)(char-int b)))))
184 (if (setq as (char-total-strokes a))
185 (if (setq bs (char-total-strokes b))
187 (ideograph-char< a b)
190 (ideograph-char< a b))))
192 (unless (memq c ignored-chars)
193 (setq is (char-feature c 'ideographic-structure))
195 (www-ids-find-format-line c is)
198 (www-ids-insert-chars-including-components
200 (cons c ignored-chars)))
206 (defun www-batch-ids-find ()
207 (let ((components (car command-line-args-left))
208 (coded-charset-entity-reference-alist
210 '(=cns11643-1 "C1-" 4 X)
211 '(=cns11643-2 "C2-" 4 X)
212 '(=cns11643-3 "C3-" 4 X)
213 '(=cns11643-4 "C4-" 4 X)
214 '(=cns11643-5 "C5-" 4 X)
215 '(=cns11643-6 "C6-" 4 X)
216 '(=cns11643-7 "C7-" 4 X)
218 '(=gb12345 "G1-" 4 X)
219 '(=jis-x0208@1990 "J90-" 4 X)
220 '(=jis-x0212 "JSP-" 4 X)
222 '(=jef-china3 "JC3-" 4 X)
223 '(=jis-x0208@1978 "J78-" 4 X)
224 '(=jis-x0208@1983 "J83-" 4 X)
225 '(=daikanwa "M-" 5 d)
226 coded-charset-entity-reference-alist))
228 (setq command-line-args-left (cdr command-line-args-left))
230 ((stringp components)
231 (if (string-match "^components=" components)
232 (setq components (substring components (match-end 0))))
234 (if (> (length components) 0)
235 (decode-url-string components 'utf-8-jp-er)
239 (setq components nil)
241 (princ "Content-Type: text/html; charset=UTF-8
243 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
244 \"http://www.w3.org/TR/html4/loose.dtd\">
247 <title>CHISE IDS Find</title>
253 (princ (encode-coding-string "CHISE IDS
\e$B4A;z8!:w
\e(B" 'utf-8-jp-er))
257 (princ www-ids-find-version)
258 (princ (format-time-string
259 " (Last-modified: %Y-%m-%d %H:%M:%S)"
262 www-ids-find-ideographic-products-file-name))))
265 Copyright (C) 2005 <a href=\"http://kanji.zinbun.kyoto-u.ac.jp/~tomo/\"
266 >MORIOKA Tomohiko</a>
269 <form action=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/ids-find\" method=\"GET\">
271 (princ (encode-coding-string "
\e$BItIJJ8;zNs
\e(B" 'utf-8-jp-er))
272 (princ " <input type=\"text\" name=\"components\" size=\"30\" maxlength=\"30\" value=\"")
273 (if (> (length components) 0)
274 (princ (encode-coding-string components 'utf-8-jp-er)))
276 <input type=\"submit\" value=\"")
277 (princ (encode-coding-string "
\e$B8!:w3+;O
\e(B" 'utf-8-jp-er))
282 (unless (file-newer-than-file-p
283 www-ids-find-ideographic-products-file-name
284 (locate-file (car command-line-args) exec-path))
285 (princ (encode-coding-string "<hr>
287 \e$B8=:_!"%7%9%F%`$N99?7:n6HCf$G$9!#$7$P$i$/$*BT$A$/$@$5$$!#
\e(B
290 ;; (setq components nil)
294 ;; (map-char-attribute
296 ;; (when (every (lambda (p)
297 ;; (ideographic-structure-member p v))
299 ;; (princ (encode-coding-string
300 ;; (ids-find-format-line c v)
305 ;; 'ideographic-structure)
306 (when (= (length components) 1)
307 (www-ids-find-format-line (aref components 0)
308 (char-feature (aref components 0)
309 'ideographic-structure)))
310 ;; (dolist (c (ideographic-products-find components))
311 ;; (setq is (char-feature c 'ideographic-structure))
312 ;; ;; to avoid problems caused by wrong indexes
313 ;; (when (every (lambda (c)
314 ;; (ideographic-structure-member c is))
316 ;; (www-ids-find-format-line c is)))
318 (www-ids-insert-chars-including-components components)
322 (princ (encode-coding-string "<hr>
324 \e$B;XDj$7$?ItIJ$rA4$F4^$`4A;z$N0lMw$rI=<($7$^$9!#
\e(B
326 CHISE
\e$B$GMQ$$$i$l$k<BBV;2>H7A<0!JNc!'
\e(B&M-00256;
\e$B!K$GItIJ$r;XDj$9$k;v$b$G$-$^$9!#
\e(B" 'utf-8-jp-er))
327 (princ (encode-coding-string "
331 <li><a href=\"http://www.shuiren.org/chuden/toyoshi/syoseki/chise_ids.html\"
332 >
\e$B!V
\e(BCHISE IDS FIND
\e$B$G4A;z$r8!:w!W
\e(B</a>
\e$B!=
\e(B
\e$B;3ED?r?N$5$s!J
\e(B<a
333 href=\"http://www.shuiren.org/\">
\e$B?g?MDb
\e(B</a>
\e$B!K$K$h$k2r@b
\e(B
336 <li><a href=\"http://www.karitsu.org/tools/firefox_plugin.htm\"
337 >Firefox
\e$BMQ
\e(B plugin</a> by
\e$B=);3M[0lO:$5$s!J
\e(B<a href=\"http://www.karitsu.org/\"
338 >
\e$B2aN)c7
\e(B</a>
\e$B!K
\e(B
341 <li><a href=\"http://cvs.m17n.org/viewcvs/chise/ids/www/www-ids-find.el?view=markup\"
342 >www-ids-find.el (source file (Emacs Lisp part))
343 <li><a href=\"http://kanji.zinbun.kyoto-u.ac.jp/projects/chise/ids/\"
344 >
\e$B!V
\e(BCHISE
\e$B4A;z9=B$>pJs%G!<%?%Y!<%9!W
\e(B</a>
345 <li><a href=\"http://fonts.jp/chise_linkmap/\"
346 >
\e$B!V
\e(Bchise_linkmap : CHISE
\e$B4A;zO"4D?^!W
\e(B</a> by
\e$B>eCO9(0l$5$s
\e(B
347 <li><a href=\"http://kanji.zinbun.kyoto-u.ac.jp/projects/chise/\"
351 <li><a href=\"http://coe21.zinbun.kyoto-u.ac.jp/djvuchar\"
352 >
\e$B!VBsK\J8;z%G!<%?%Y!<%9!W
\e(B</a> by
353 <a href=\"http://coe21.zinbun.kyoto-u.ac.jp/\"
354 >
\e$B5~ETBg3X
\e(B21
\e$B@$5*
\e(BCOE
\e$B!VEl%"%8%"@$3&$N?MJ8>pJs3X8&5f650i5rE@!W
\e(B</a>
355 <li><a href=\"http://www.unicode.org/\"
365 href=\"http://kanji.zinbun.kyoto-u.ac.jp/projects/chise/xemacs/\"
366 >XEmacs CHISE</a> %s."
367 xemacs-chise-version))