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.24.2")
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-chise-link-map-url-prefix
29 "http://kamichi.jp/chise_linkmap/map.cgi?code=")
31 (defvar www-ids-find-tang-chars-file-name
32 "~tomo/projects/chise/ids/www/tang-chars.udd")
34 (defun www-ids-find-format-char (c &optional code-desc)
35 (let ((str (encode-coding-string (format "%c" c) 'utf-8-er))
40 ((string-match "&CB\\([0-9]+\\);" str)
41 (setq code (string-to-int (match-string 1 str)))
42 (insert "<a href=\"/char-desc?char=")
44 (insert (format "\"><img alt=\"CB%05d\" src=\"/glyphs/cb-gaiji/%02d/CB%05d.gif\">\n"
45 code (/ code 1000) code))
47 (insert (format "CB%05d</a>" code)))
49 ((string-match "&JC3-\\([0-9A-F]+\\);" str)
50 (setq code (string-to-int (match-string 1 str) 16))
51 (insert "<a href=\"/char-desc?char=")
53 (insert (format "\"><img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">\n"
56 (insert (format "JC3-%04X</a>" code)))
58 ((string-match "&J\\(78\\|83\\|90\\|SP\\)-\\([0-9A-F]+\\);" str)
59 (setq plane (match-string 1 str)
60 code (string-to-int (match-string 2 str) 16))
61 (insert "<a href=\"/char-desc?char=")
63 (insert (format "\"><img alt=\"J%s-%04X\" src=\"/glyphs/JIS-%s/%02d-%02d.gif\">\n"
66 (- (logand code 255) 32)))
68 (insert (format "J%s-%04X</a>" plane code)))
70 ((string-match "&G\\([01]\\)-\\([0-9A-F]+\\);" str)
71 (setq plane (string-to-int (match-string 1 str))
72 code (string-to-int (match-string 2 str) 16))
73 (insert "<a href=\"/char-desc?char=")
75 (insert (format "\"><img alt=\"G%d-%04X\" src=\"/glyphs/GB%d/%02d-%02d.gif\">\n"
78 (- (logand code 255) 32)))
80 (insert (format "G%d-%04X</a>" plane code)))
82 ((string-match "&C\\([1-7]\\)-\\([0-9A-F]+\\);" str)
83 (setq plane (string-to-int (match-string 1 str))
84 code (string-to-int (match-string 2 str) 16))
85 (insert "<a href=\"/char-desc?char=")
87 (insert (format "\"><img alt=\"C%d-%04X\" src=\"/glyphs/CNS%d/%04X.gif\">\n"
88 plane code plane code))
90 (insert (format "C%d-%04X</a>" plane code)))
92 ((string-match "&ZOB-\\([0-9]+\\);" str)
93 (setq code (string-to-int (match-string 1 str)))
94 (insert "<a href=\"/char-desc?char=")
96 (insert (format "\"><img alt=\"ZOB-%04d\" src=\"/glyphs/ZOB-1968/%04d.png\">\n"
99 (insert (format "ZOB-%04d</a>" code)))
102 (insert "<a href=\"/char-desc?char=")
105 (mapconcat (lambda (c)
106 (if (<= (char-int c) #x7F)
108 (format "%%%02X" c)))
114 (goto-char (point-min))
115 (while (search-forward "&" nil t)
116 (replace-match "&" t 'literal))
119 (defun www-ids-find-format-line (c is)
121 (www-ids-find-format-char c 'code-desc)
123 (or (if (setq ucs (or (char-ucs c)
124 (encode-char c 'ucs)))
126 " <a href=\"http://www.unicode.org/cgi-bin/GetUnihanData.pl?codepoint=%X\">%s</a>"
128 (cond ((<= ucs #xFFFF)
129 (format "U+%04X" ucs))
131 (format "U-%08X" ucs))))
135 (format " <a href=\"%s%X\">(link map)</a>"
136 www-ids-find-chise-link-map-url-prefix ucs)))
139 (setq ids (ideographic-structure-to-ids is))
143 (www-ids-find-format-char (aref ids i))
148 www-ids-find-tang-chars-file-name)
149 (goto-char (point-min))
150 (re-search-forward (format "^%d$" ucs) nil t)))
152 (format " <a href=\"http://coe21.zinbun.kyoto-u.ac.jp/djvuchar?query=%s\">"
155 (format "%%%02X" (char-int c)))
156 (encode-coding-string (char-to-string c)
159 (princ (encode-coding-string "
\e$B"M
\e(B[
\e$BEbBeBsK\
\e(B]</a>" 'utf-8-jp-er)))
162 (defun www-ids-insert-chars-including-components (components
163 &optional ignored-chars)
164 (let ((products (copy-list (ideographic-products-find components)))
165 is as bs len ignore-children)
166 (setq len (length products))
169 (setq ignore-children t)
174 (< (char-int a)(char-int b))))
179 (if (setq as (char-total-strokes a))
180 (if (setq bs (char-total-strokes b))
182 (< (char-int a)(char-int b))
185 (< (char-int a)(char-int b)))))
190 (if (setq as (char-total-strokes a))
191 (if (setq bs (char-total-strokes b))
193 (ideograph-char< a b)
196 (ideograph-char< a b))))
198 (unless (memq c ignored-chars)
199 (setq is (char-feature c 'ideographic-structure))
201 (www-ids-find-format-line c is)
202 (unless ignore-children
205 (www-ids-insert-chars-including-components
207 (cons c ignored-chars)))
213 (defun www-batch-ids-find ()
214 (let ((components (car command-line-args-left))
215 (coded-charset-entity-reference-alist
217 '(=cns11643-1 "C1-" 4 X)
218 '(=cns11643-2 "C2-" 4 X)
219 '(=cns11643-3 "C3-" 4 X)
220 '(=cns11643-4 "C4-" 4 X)
221 '(=cns11643-5 "C5-" 4 X)
222 '(=cns11643-6 "C6-" 4 X)
223 '(=cns11643-7 "C7-" 4 X)
225 '(=gb12345 "G1-" 4 X)
226 '(=jis-x0208@1990 "J90-" 4 X)
227 '(=jis-x0212 "JSP-" 4 X)
229 '(=jef-china3 "JC3-" 4 X)
230 '(=jis-x0208@1978 "J78-" 4 X)
231 '(=jis-x0208@1983 "J83-" 4 X)
232 '(=daikanwa "M-" 5 d)
233 coded-charset-entity-reference-alist))
235 (setq command-line-args-left (cdr command-line-args-left))
237 ((stringp components)
238 (if (string-match "^components=" components)
239 (setq components (substring components (match-end 0))))
241 (if (> (length components) 0)
242 (decode-url-string components 'utf-8-er)
246 (setq components nil)
248 (princ "Content-Type: text/html; charset=UTF-8
250 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
251 \"http://www.w3.org/TR/html4/loose.dtd\">
254 <title>CHISE IDS Find</title>
260 (princ (encode-coding-string "CHISE IDS
\e$B4A;z8!:w
\e(B" 'utf-8-jp-er))
264 (princ www-ids-find-version)
265 (princ (format-time-string
266 " (Last-modified: %Y-%m-%d %H:%M:%S)"
269 www-ids-find-ideographic-products-file-name))))
273 <form action=\"/ids-find\" method=\"GET\">
275 (princ (encode-coding-string "
\e$BItIJJ8;zNs
\e(B" 'utf-8-jp-er))
276 (princ " <input type=\"text\" name=\"components\" size=\"30\" maxlength=\"30\" value=\"")
277 (if (> (length components) 0)
278 (princ (encode-coding-string components 'utf-8-er)))
280 <input type=\"submit\" value=\"")
281 (princ (encode-coding-string "
\e$B8!:w3+;O
\e(B" 'utf-8-jp-er))
286 (unless (file-newer-than-file-p
287 www-ids-find-ideographic-products-file-name
288 (locate-file (car command-line-args) exec-path))
289 (princ (encode-coding-string "<hr>
291 \e$B8=:_!"%7%9%F%`$N99?7:n6HCf$G$9!#$7$P$i$/$*BT$A$/$@$5$$!#
\e(B
294 ;; (setq components nil)
298 ;; (map-char-attribute
300 ;; (when (every (lambda (p)
301 ;; (ideographic-structure-member p v))
303 ;; (princ (encode-coding-string
304 ;; (ids-find-format-line c v)
309 ;; 'ideographic-structure)
310 (when (= (length components) 1)
311 (www-ids-find-format-line (aref components 0)
312 (char-feature (aref components 0)
313 'ideographic-structure)))
314 ;; (dolist (c (ideographic-products-find components))
315 ;; (setq is (char-feature c 'ideographic-structure))
316 ;; ;; to avoid problems caused by wrong indexes
317 ;; (when (every (lambda (c)
318 ;; (ideographic-structure-member c is))
320 ;; (www-ids-find-format-line c is)))
322 (www-ids-insert-chars-including-components components)
326 (princ (encode-coding-string "<hr>
328 \e$B;XDj$7$?ItIJ$rA4$F4^$`4A;z$N0lMw$rI=<($7$^$9!#
\e(B
330 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))
331 (princ (encode-coding-string "
335 <li><a href=\"http://www.shuiren.org/chuden/toyoshi/syoseki/chise_ids.html\"
336 >
\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
337 href=\"http://www.shuiren.org/\">
\e$B?g?MDb
\e(B</a>
\e$B!K$K$h$k2r@b
\e(B
340 <li><a href=\"http://www.karitsu.org/tools/firefox_plugin.htm\"
341 >Firefox
\e$BMQ
\e(B plugin</a> by
\e$B=);3M[0lO:$5$s!J
\e(B<a href=\"http://www.karitsu.org/\"
342 >
\e$B2aN)c7
\e(B</a>
\e$B!K
\e(B
345 <li><a href=\"http://cvs.m17n.org/viewcvs/chise/ids/www/www-ids-find.el?view=markup\"
346 >www-ids-find.el (source file (Emacs Lisp part))
347 <li><a href=\"http://kanji.zinbun.kyoto-u.ac.jp/projects/chise/ids/\"
348 >
\e$B!V
\e(BCHISE
\e$B4A;z9=B$>pJs%G!<%?%Y!<%9!W
\e(B</a>
349 <li><a href=\"http://fonts.jp/chise_linkmap/\"
350 >
\e$B!V
\e(Bchise_linkmap : CHISE
\e$B4A;zO"4D?^!W
\e(B</a> by
\e$B>eCO9(0l$5$s
\e(B
351 <li><a href=\"http://kanji.zinbun.kyoto-u.ac.jp/projects/chise/\"
355 <li><a href=\"http://coe21.zinbun.kyoto-u.ac.jp/djvuchar\"
356 >
\e$B!VBsK\J8;z%G!<%?%Y!<%9!W
\e(B</a> by
357 <a href=\"http://coe21.zinbun.kyoto-u.ac.jp/\"
358 >
\e$B5~ETBg3X
\e(B21
\e$B@$5*
\e(BCOE
\e$B!VEl%"%8%"@$3&$N?MJ8>pJs3X8&5f650i5rE@!W
\e(B</a>
359 <li><a href=\"http://www.unicode.org/\"
367 Copyright (C) 2005, 2006, 2007, 2008, 2009 <a href=\"http://kanji.zinbun.kyoto-u.ac.jp/~tomo/\"
368 >MORIOKA Tomohiko</a>")
372 href=\"http://kanji.zinbun.kyoto-u.ac.jp/projects/chise/xemacs/\"
373 >XEmacs CHISE</a> %s."
374 xemacs-chise-version))