2 (require 'cwiki-common)
4 (defun www-format-encode-string (string &optional without-tags as-body)
7 (let (plane code subcode start end char variants ret rret)
9 (goto-char (point-min))
10 (while (search-forward "&" nil t)
11 (replace-match "&" nil t)))
12 (goto-char (point-min))
13 (while (search-forward "<" nil t)
14 (replace-match "<" nil t))
15 (goto-char (point-min))
16 (while (search-forward ">" nil t)
17 (replace-match ">" nil t))
19 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
20 (let ((coded-charset-entity-reference-alist
24 '(=hanyo-denshi/ja "HD-JA-" 4 X)
25 '(=hanyo-denshi/jb "HD-JB-" 4 X)
26 '(=hanyo-denshi/jc "HD-JC-" 4 X)
27 '(=hanyo-denshi/jd "HD-JD-" 4 X)
28 '(=hanyo-denshi/ft "HD-FT-" 4 X)
29 '(=hanyo-denshi/ia "HD-IA-" 4 X)
30 '(=hanyo-denshi/ib "HD-IB-" 4 X)
31 '(=hanyo-denshi/hg "HD-HG-" 4 X)
32 '(=hanyo-denshi/ip "HD-IP-" 4 X)
33 '(=hanyo-denshi/jt "HD-JT-" 4 X)
34 '(=hanyo-denshi/ks "HD-KS-" 6 d)
35 '(=>>hanyo-denshi/ja "G-HD-JA-" 4 X)
36 '(=>>hanyo-denshi/jb "G-HD-JB-" 4 X)
37 '(=>>hanyo-denshi/jc "G-HD-JC-" 4 X)
38 '(=>>hanyo-denshi/jd "G-HD-JD-" 4 X)
39 '(=>>hanyo-denshi/ft "G-HD-FT-" 4 X)
40 '(=>>hanyo-denshi/ia "G-HD-IA-" 4 X)
41 '(=>>hanyo-denshi/ib "G-HD-IB-" 4 X)
42 '(=>>hanyo-denshi/hg "G-HD-HG-" 4 X)
43 '(=>>hanyo-denshi/ip "G-HD-IP-" 4 X)
44 '(=>>hanyo-denshi/jt "G-HD-JT-" 4 X)
45 '(=>>hanyo-denshi/ks "G-HD-KS-" 6 d)
47 '(==hanyo-denshi/ja "g2-HD-JA-" 4 X)
48 '(==hanyo-denshi/jb "g2-HD-JB-" 4 X)
49 '(==hanyo-denshi/jc "g2-HD-JC-" 4 X)
50 '(==hanyo-denshi/jd "g2-HD-JD-" 4 X)
51 '(==hanyo-denshi/ft "g2-HD-FT-" 4 X)
52 '(==hanyo-denshi/ia "g2-HD-IA-" 4 X)
53 '(==hanyo-denshi/ib "g2-HD-IB-" 4 X)
54 '(==hanyo-denshi/hg "g2-HD-HG-" 4 X)
55 '(==hanyo-denshi/ip "g2-HD-IP-" 4 X)
56 '(==hanyo-denshi/jt "g2-HD-JT-" 4 X)
57 '(==hanyo-denshi/ks "g2-HD-KS-" 6 d)
58 '(==daijiten "g2-DJT-" 5 d)
59 '(=cns11643-1 "C1-" 4 X)
60 '(=cns11643-2 "C2-" 4 X)
61 '(=cns11643-3 "C3-" 4 X)
62 '(=cns11643-4 "C4-" 4 X)
63 '(=cns11643-5 "C5-" 4 X)
64 '(=cns11643-6 "C6-" 4 X)
65 '(=cns11643-7 "C7-" 4 X)
66 '(=adobe-japan1-6 "AJ1-" 5 d)
67 '(=big5-cdp "CDP-" 4 X)
68 '(=>big5-cdp "A-CDP-" 4 X)
71 '(=jis-x0208@1990 "J90-" 4 X)
72 '(=jis-x0212 "JSP-" 4 X)
74 '(=jis-x0208@1997 "J97-" 4 X)
75 '(=jis-x0208@1978 "J78-" 4 X)
76 '(=jis-x0208@1983 "J83-" 4 X)
77 '(=ruimoku-v6 "RUI6-" 4 X)
78 '(=zinbun-oracle "ZOB-" 4 d)
79 '(=daijiten "DJT-" 5 d)
80 '(=jef-china3 "JC3-" 4 X)
81 '(=ucs@unicode "UU+" 4 X)
82 '(=ucs@JP/hanazono "hanaJU+" 4 X)
83 '(==cns11643-1 "R-C1-" 4 X)
84 '(==cns11643-2 "R-C2-" 4 X)
85 '(==cns11643-3 "R-C3-" 4 X)
86 '(==cns11643-4 "R-C4-" 4 X)
87 '(==cns11643-5 "R-C5-" 4 X)
88 '(==cns11643-6 "R-C6-" 4 X)
89 '(==cns11643-7 "R-C7-" 4 X)
90 '(=hanziku-1 "HZK01-" 4 X)
91 '(=hanziku-2 "HZK02-" 4 X)
92 '(=hanziku-3 "HZK03-" 4 X)
93 '(=hanziku-4 "HZK04-" 4 X)
94 '(=hanziku-5 "HZK05-" 4 X)
95 '(=hanziku-6 "HZK06-" 4 X)
96 '(=hanziku-7 "HZK07-" 4 X)
97 '(=hanziku-8 "HZK08-" 4 X)
98 '(=hanziku-9 "HZK09-" 4 X)
99 '(=hanziku-10 "HZK10-" 4 X)
100 '(=hanziku-11 "HZK11-" 4 X)
101 '(=hanziku-12 "HZK12-" 4 X)
102 '(==>daijiten "A2-DJT-" 5 d)
105 '(=daikanwa "M-" 5 d)
106 '(=>>daikanwa "G-M-" 5 d)
107 '(===ucs@ks "R-KU+" 4 X)
108 coded-charset-entity-reference-alist)))
109 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
111 (goto-char (point-min))
112 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\|R-\\)?CB\\([0-9]+\\);" nil t)
113 (setq code (string-to-int (match-string 2)))
115 (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
118 chise-wiki-legacy-bitmap-glyphs-url
120 www-format-char-img-style)
123 (goto-char (point-min))
124 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?J\\(78\\|83\\|90\\|97\\|SP\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
125 (setq plane (match-string 2)
126 code (string-to-int (match-string 3) 16))
128 (format "<img alt=\"J%s-%04X\" src=\"%s/JIS-%s/%02d-%02d.gif\"
131 chise-wiki-legacy-bitmap-glyphs-url
134 (- (logand code 255) 32)
135 www-format-char-img-style)
138 (goto-char (point-min))
139 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?J0-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
140 (setq code (string-to-int (match-string 2) 16))
142 (format "<img alt=\"J0-%04X\" src=\"%s/JIS-90/%02d-%02d.gif\"
145 chise-wiki-legacy-bitmap-glyphs-url
147 (- (logand code 255) 32)
148 www-format-char-img-style)
151 (goto-char (point-min))
152 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-\\(JA\\|JB\\|JC\\|JD\\|FT\\|IA\\|IB\\|HG\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
153 (setq plane (match-string 2)
154 code (string-to-int (match-string 3) 16))
156 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%02d%02d.png\"
159 chise-wiki-legacy-bitmap-glyphs-url
162 (- (logand code 255) 32)
163 www-format-char-img-style)
166 (goto-char (point-min))
167 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-\\(IP\\|JT\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
168 (setq plane (match-string 2)
169 code (string-to-int (match-string 3) 16))
171 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%04X.png\"
174 chise-wiki-legacy-bitmap-glyphs-url
176 www-format-char-img-style)
179 (goto-char (point-min))
180 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-KS-\\([0-9]+\\);" nil t)
181 (setq code (string-to-int (match-string 2)))
183 (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/KS%06d.png\"
184 style=\"vertical-align:middle\">"
186 chise-wiki-legacy-bitmap-glyphs-url
188 www-format-char-img-style)
191 (goto-char (point-min))
192 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-TK-\\([0-9]+\\);" nil t)
193 (setq code (string-to-int (match-string 2)))
195 (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/TK%08d.png\"
196 style=\"vertical-align:middle\">"
198 chise-wiki-legacy-bitmap-glyphs-url
200 www-format-char-img-style)
203 (goto-char (point-min))
204 (while (re-search-forward "&G\\([01]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
205 (setq plane (string-to-int (match-string 1))
206 code (string-to-int (match-string 2) 16))
208 (format "<img alt=\"GB%d-%04X\" src=\"%s/GB%d/%02d-%02d.gif\"
211 chise-wiki-legacy-bitmap-glyphs-url
214 (- (logand code 255) 32)
215 www-format-char-img-style)
218 (goto-char (point-min))
219 (while (re-search-forward "&\\(R-\\)?C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
220 (setq plane (string-to-int (match-string 2))
221 code (string-to-int (match-string 3) 16))
223 (format "<img alt=\"CNS%d-%04X\" src=\"%s/CNS%d/%04X.gif\"
226 chise-wiki-legacy-bitmap-glyphs-url
228 www-format-char-img-style)
231 (goto-char (point-min))
232 (while (re-search-forward "&\\(R-\\)?JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
233 (setq code (string-to-int (match-string 2) 16))
235 (format "<img alt=\"JC3-%04X\" src=\"%s/JEF-CHINA3/%04X.png\">"
236 code chise-wiki-bitmap-glyph-image-url code)
239 (goto-char (point-min))
240 (while (re-search-forward "&\\(A-\\)?ZOB-\\([0-9]+\\);" nil t)
241 (setq code (string-to-int (match-string 2)))
243 (format "<img alt=\"ZOB-%04d\" src=\"%s/ZOB-1968/%04d.png\"
244 style=\"vertical-align:middle\">"
246 chise-wiki-legacy-bitmap-glyphs-url
248 www-format-char-img-style)
251 (goto-char (point-min))
252 (while (re-search-forward "&\\(A2-\\|g2-\\|R-\\)?DJT-\\([0-9]+\\);" nil t)
253 (setq code (string-to-int (match-string 2)))
255 (format "<img alt=\"DJT-%05d\" src=\"%s/%05d.png\"
256 style=\"vertical-align:middle; width: auto; max-height: 60px\">"
258 chise-wiki-daijiten-bitmap-glyphs-url
260 www-format-char-img-style)
263 (goto-char (point-min))
264 (while (re-search-forward "&SW-JIGUGE\\([45]?\\)-\\([0-9]+\\);" nil t)
265 (setq subcode (match-string 1)
266 code (string-to-int (match-string 2)))
268 (if (string= subcode "")
272 (format "<img alt=\"SW-JIGUGE%s-%05d\" src=\"%s/ShuoWen/Jiguge%s/%05d.png\"
273 style=\"vertical-align:middle; width: auto; max-height: 80px\">"
275 chise-wiki-legacy-bitmap-glyphs-url
279 (goto-char (point-min))
280 (while (re-search-forward "&HNG\\([0-9]+\\)-\\([0-9][0-9][0-9][0-9]\\)\\([0-9]\\);" nil t)
281 (setq plane (match-string 1)
282 code (string-to-int (match-string 2))
283 subcode (string-to-int (match-string 3)))
287 (char-to-string (decode-char 'ascii (+ 96 subcode)))))
290 "<img alt=\"HNG%s-%04d%s\" src=\"%s/%s/%04d%s.png\" style=\"
291 vertical-align:middle; width: auto; max-height: 60px\">"
293 chise-wiki-hng-bitmap-glyphs-url
298 (goto-char (point-min))
299 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?AJ1-\\([0-9]+\\);" nil t)
300 (setq code (string-to-int (match-string 2)))
302 (format "<img alt=\"AJ1-%05d\" src=\"%s/IVD/AdobeJapan1/CID+%d.png\"
303 style=\"vertical-align:middle\">"
305 chise-wiki-legacy-bitmap-glyphs-url
307 www-format-char-img-style)
310 (goto-char (point-min))
311 (while (re-search-forward "&\\(A-\\|o-\\|G-\\|g2-\\|R-\\)?MJ\\([0-9]+\\);" nil t)
312 (setq code (string-to-int (match-string 2)))
314 (format "<img alt=\"MJ%06d\" src=\"https://moji.or.jp/mojikibansearch/img/MJ/MJ%06d.png\"
315 style=\"vertical-align:middle; width: 48px; height: 48px\">"
318 www-format-char-img-style)
321 (goto-char (point-min))
322 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?IU[+-]\\([0-9A-F]+\\);" nil t)
323 (setq code (string-to-int (match-string 2) 16))
325 (format "<img alt=\"u%04x\" src=\"%s/u%04x.svg\"
326 style=\"vertical-align:middle; width: 48px; height: 48px\">"
328 chise-wiki-glyphwiki-glyph-image-url
330 www-format-char-img-style)
333 (goto-char (point-min))
334 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?KU[+-]\\([0-9A-F]+\\);" nil t)
335 (setq code (string-to-int (match-string 2) 16))
337 (format "<img alt=\"u%04x-k\" src=\"%s/u%04x-k.svg\"
338 style=\"vertical-align:middle; width: 48px; height: 48px\">"
340 chise-wiki-glyphwiki-glyph-image-url
342 www-format-char-img-style)
345 (goto-char (point-min))
346 (while (re-search-forward "&A-\\(comp\\|cgn\\)U[+-]\\([0-9A-F]+\\);" nil t)
347 (setq code (string-to-int (match-string 2) 16))
349 (format "<img alt=\"u%04x\" src=\"%s/u%04x.svg\"
350 style=\"vertical-align:middle; width: 48px; height: 48px\">"
352 chise-wiki-glyphwiki-glyph-image-url
354 www-format-char-img-style)
357 (goto-char (point-min))
358 (while (re-search-forward
359 "&\\(A-\\|g2-\\)?U-i\\([0-9]+\\)\\+\\([0-9A-F]+\\);"
361 (setq plane (string-to-int (match-string 2))
362 code (string-to-int (match-string 3) 16))
364 (format "<img alt=\"u%04x-itaiji-%03d\" src=\"%s/u%04x-itaiji-%03d.svg\"
365 style=\"vertical-align:middle; width: 48px; height: 48px\">"
368 chise-wiki-glyphwiki-glyph-image-url
371 www-format-char-img-style)
374 (goto-char (point-min))
375 (while (re-search-forward "&A-IWDSU\\+\\([0-9A-F]+\\);" nil t)
376 (setq code (string-to-int (match-string 1) 16))
378 (format "<img alt=\"A-IWDSU+%04x\" src=\"%s/u%04x.svg\"
379 style=\"vertical-align:middle; width: 48px; height: 48px\">"
381 chise-wiki-glyphwiki-glyph-image-url
383 www-format-char-img-style)
386 (goto-char (point-min))
387 (while (re-search-forward
388 "&\\(A-\\)?CDP-i\\([0-9]+\\)-\\([0-9A-F]+\\);"
390 (setq plane (string-to-int (match-string 2))
391 code (string-to-int (match-string 3) 16))
393 (format "<img alt=\"cdp-%04x-itaiji-%03d\" src=\"%s/cdp-%04x-itaiji-%03d.svg\"
394 style=\"vertical-align:middle; width: 48px; height: 48px\">"
397 chise-wiki-glyphwiki-glyph-image-url
400 www-format-char-img-style)
403 (goto-char (point-min))
404 (while (re-search-forward
405 "&\\(A-\\)?CDP-v\\([0-9]+\\)-\\([0-9A-F]+\\);"
407 (setq plane (string-to-int (match-string 2))
408 code (string-to-int (match-string 3) 16))
410 (format "<img alt=\"cdp-%04x-var-%03d\" src=\"%s/cdp-%04x-var-%03d.svg\"
411 style=\"vertical-align:middle; width: 48px; height: 48px\">"
414 chise-wiki-glyphwiki-glyph-image-url
417 www-format-char-img-style)
420 (goto-char (point-min))
421 (while (re-search-forward
422 "&\\(A-\\|G-\\|g2-\\|R-\\)?M-\\([0-9]+\\);"
424 (setq code (string-to-int (match-string 2)))
426 (format "<img alt=\"dkw-%05d\" src=\"%s/dkw-%05d.svg\"
427 style=\"vertical-align:middle; width: 48px; height: 48px\">"
429 chise-wiki-glyphwiki-glyph-image-url
431 www-format-char-img-style)
434 (goto-char (point-min))
435 (while (re-search-forward "&\\(g2-\\)?U-v\\([0-9]+\\)\\+\\([0-9A-F]+\\);" nil t)
436 (setq plane (string-to-int (match-string 2))
437 code (string-to-int (match-string 3) 16))
439 (format "<img alt=\"u%04x-var-%03d\" src=\"%s/u%04x-var-%03d.svg\"
440 style=\"vertical-align:middle; width: 48px; height: 48px\">"
443 chise-wiki-glyphwiki-glyph-image-url
446 www-format-char-img-style)
449 (goto-char (point-min))
450 (while (re-search-forward "&\\(A-\\|G-\\|R-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
451 (setq code (string-to-int (match-string 2)))
453 (format "<img alt=\"GT-%05d\" src=\"%s?char=GT-%05d\"
456 chise-wiki-glyph-cgi-url
458 www-format-char-img-style)
461 (goto-char (point-min))
462 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\)?GT-K\\([0-9]+\\);" nil t)
463 (setq code (string-to-int (match-string 2)))
465 (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\"
468 chise-wiki-glyph-cgi-url
470 www-format-char-img-style)
473 (goto-char (point-min))
474 (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
475 (setq code (string-to-int (match-string 1) 16))
477 (format "<img alt=\"B-%04X\" src=\"%s?char=B-%04X\"
480 chise-wiki-glyph-cgi-url
482 www-format-char-img-style)
485 (goto-char (point-min))
486 (while (re-search-forward
487 "&\\(A-\\|G-\\|g2-\\|R-\\)?CDP-\\([0-9A-F]+\\);" nil t)
488 (setq code (string-to-int (match-string 2) 16))
490 (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
493 chise-wiki-glyph-cgi-url
495 www-format-char-img-style)
498 (goto-char (point-min))
499 (while (re-search-forward
500 "&\\(I-\\)?HZK\\(0[1-9]\\|1[0-2]\\)-\\([0-9A-F]+\\);" nil t)
501 (setq plane (match-string 2)
502 code (string-to-int (match-string 3) 16))
504 (format "<img alt=\"HZK%s-%04X\" src=\"%s?char=HZK%s-%04X\"
508 chise-wiki-glyph-cgi-url
511 www-format-char-img-style)
514 (goto-char (point-min))
515 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\|R-\\)?RUI6-\\([0-9A-F]+\\);" nil t)
516 (setq code (string-to-int (match-string 2) 16))
518 (format "<img alt=\"RUI6-%04X\" src=\"%s?char=RUI6-%04X\"
519 style=\"vertical-align:middle\">"
521 chise-wiki-glyph-cgi-url
523 www-format-char-img-style)
526 (goto-char (point-min))
527 (while (re-search-forward "&hanaJU\\+\\([0-9A-F]+\\);" nil t)
528 (setq code (string-to-int (match-string 1) 16))
530 (format "<img alt=\"hanaJU+%04X\" src=\"%s?char=hana-JU+%04X\"
531 style=\"vertical-align:middle\">"
533 chise-wiki-glyph-cgi-url
535 www-format-char-img-style)
538 (goto-char (point-min))
539 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\|R-\\)?\\(UU\\+\\|U-\\)\\([0-9A-F]+\\);" nil t)
540 (setq code (string-to-int (match-string 3) 16))
542 (format "<img alt=\"UU+%04X\" src=\"https://www.unicode.org/cgi-bin/refglyph?24-%04X\"
543 style=\"vertical-align:middle\">"
546 www-format-char-img-style)
549 (goto-char (point-min))
550 (while (re-search-forward "&MCS-\\([0-9A-F]+\\);" nil t)
551 (setq code (string-to-int (match-string 1) 16))
552 (setq start (match-beginning 0)
554 (setq char (decode-char 'system-char-id code))
557 (or (www-get-feature-value char '->subsumptive)
558 (www-get-feature-value char '->denotational)))
560 (if (characterp variants)
561 (setq variants (list variants)))
563 (setq ret (www-format-encode-string
564 (char-to-string (car variants))))
565 (string-match "&MCS-\\([0-9A-F]+\\);" ret))
566 (setq variants (cdr variants)))
568 (unless (string-match "&MCS-\\([0-9A-F]+\\);" ret)
570 (delete-region start end)
573 ((setq ret (or (www-get-feature-value char 'ideographic-combination)
574 (www-get-feature-value char 'ideographic-structure)))
579 (if (characterp (setq rret (find-char ch)))
582 (www-format-encode-string
583 (char-to-string ch) without-tags)
584 (www-format-encode-string
585 (format "%S" ch) without-tags)))
589 (delete-region start end)
593 ;; (goto-char (point-min))
594 ;; (while (search-forward ">-" nil t)
595 ;; (replace-match "&GT-" t 'literal))
598 (setq www-format-char-img-style "vertical-align:middle;")
600 (defun decode-url-string (string &optional coding-system)
601 (if (> (length string) 0)
604 (while (string-match "%\\([0-9A-F][0-9A-F]\\)" string i)
605 (setq dest (concat dest
606 (substring string i (match-beginning 0))
609 (string-to-int (match-string 1 string) 16))))
611 (decode-coding-string
612 (concat dest (substring string i))
615 (defconst www-ids-find-version "0.99.2")
617 (defvar www-ids-find-ideographic-products-file-name
618 (expand-file-name "ideographic-products"
623 chise-system-db-directory))))
625 (defvar www-ids-find-char-viewer-url
626 "/est/view/character/")
628 (defvar www-ids-find-chise-link-map-url-prefix
629 "http://fonts.jp/chise_linkmap/map.cgi?code=")
631 (defvar www-ids-find-tang-chars-file-name
632 "~tomo/projects/chise/ids/www/tang-chars.udd")
634 (defun www-ids-find-format-char (c &optional code-desc)
636 (format "<a href=\"%s%s\">%s</a>"
637 www-ids-find-char-viewer-url
638 (www-uri-encode-object c)
639 (www-format-encode-string (char-to-string c))))
640 ;; (let ((str (encode-coding-string (format "%c" c) 'utf-8-er))
645 ;; ((string-match "&CB\\([0-9]+\\);" str)
646 ;; (setq code (string-to-int (match-string 1 str)))
647 ;; (insert (format "<a href=\"%s"
648 ;; www-ids-find-char-viewer-url))
650 ;; (insert (format "\"><img alt=\"CB%05d\" src=\"/glyphs/cb-gaiji/%02d/CB%05d.gif\">\n"
651 ;; code (/ code 1000) code))
653 ;; (insert (format "CB%05d</a>" code)))
655 ;; ((string-match "&JC3-\\([0-9A-F]+\\);" str)
656 ;; (setq code (string-to-int (match-string 1 str) 16))
657 ;; (insert (format "<a href=\"%s"
658 ;; www-ids-find-char-viewer-url))
660 ;; (insert (format "\"><img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">\n"
663 ;; (insert (format "JC3-%04X</a>" code)))
665 ;; ((string-match "&J\\(78\\|83\\|90\\|SP\\)-\\([0-9A-F]+\\);" str)
666 ;; (setq plane (match-string 1 str)
667 ;; code (string-to-int (match-string 2 str) 16))
668 ;; (insert (format "<a href=\"%s"
669 ;; www-ids-find-char-viewer-url))
671 ;; (insert (format "\"><img alt=\"J%s-%04X\" src=\"/glyphs/JIS-%s/%02d-%02d.gif\">\n"
673 ;; (- (lsh code -8) 32)
674 ;; (- (logand code 255) 32)))
676 ;; (insert (format "J%s-%04X</a>" plane code)))
678 ;; ((string-match "&G\\([01]\\)-\\([0-9A-F]+\\);" str)
679 ;; (setq plane (string-to-int (match-string 1 str))
680 ;; code (string-to-int (match-string 2 str) 16))
681 ;; (insert (format "<a href=\"%s"
682 ;; www-ids-find-char-viewer-url))
684 ;; (insert (format "\"><img alt=\"G%d-%04X\" src=\"/glyphs/GB%d/%02d-%02d.gif\">\n"
686 ;; (- (lsh code -8) 32)
687 ;; (- (logand code 255) 32)))
689 ;; (insert (format "G%d-%04X</a>" plane code)))
691 ;; ((string-match "&C\\([1-7]\\)-\\([0-9A-F]+\\);" str)
692 ;; (setq plane (string-to-int (match-string 1 str))
693 ;; code (string-to-int (match-string 2 str) 16))
694 ;; (insert (format "<a href=\"%s"
695 ;; www-ids-find-char-viewer-url))
697 ;; (insert (format "\"><img alt=\"C%d-%04X\" src=\"/glyphs/CNS%d/%04X.gif\">\n"
698 ;; plane code plane code))
700 ;; (insert (format "C%d-%04X</a>" plane code)))
702 ;; ((string-match "&ZOB-\\([0-9]+\\);" str)
703 ;; (setq code (string-to-int (match-string 1 str)))
704 ;; (insert (format "<a href=\"%s"
705 ;; www-ids-find-char-viewer-url))
707 ;; (insert (format "\"><img alt=\"ZOB-%04d\" src=\"/glyphs/ZOB-1968/%04d.png\">\n"
710 ;; (insert (format "ZOB-%04d</a>" code)))
713 ;; (insert (format "<a href=\"%s"
714 ;; www-ids-find-char-viewer-url))
717 ;; (mapconcat (lambda (c)
718 ;; (if (<= (char-int c) #x7F)
719 ;; (char-to-string c)
720 ;; (format "%%%02X" c)))
726 ;; (goto-char (point-min))
727 ;; (while (search-forward "&" nil t)
728 ;; (replace-match "&" t 'literal))
729 ;; (buffer-string))))
732 (defun www-ids-find-format-line (c is)
734 (princ "<span class=\"entry\">")
735 (www-ids-find-format-char c 'code-desc)
738 (or (if (setq ucs (or (char-ucs c)
739 (encode-char c 'ucs)))
741 " <a href=\"http://www.unicode.org/cgi-bin/GetUnihanData.pl?codepoint=%X\">%s</a>"
743 (cond ((<= ucs #xFFFF)
744 (format "U+%04X" ucs))
746 (format "U-%08X" ucs))))
750 (format " <a href=\"%s%X\">(link map)</a>"
751 www-ids-find-chise-link-map-url-prefix ucs)))
754 (setq ids (ideographic-structure-to-ids is))
757 (princ "<span class=\"ids\">")
759 (www-ids-find-format-char (aref ids i))
765 www-ids-find-tang-chars-file-name)
766 (goto-char (point-min))
767 (re-search-forward (format "^%d$" ucs) nil t)))
769 (format " <a href=\"http://coe21.zinbun.kyoto-u.ac.jp/djvuchar?query=%s\">"
772 (format "%%%02X" (char-int c)))
773 (encode-coding-string (char-to-string c)
776 (princ (encode-coding-string "
\e$B"M
\e(B[
\e$BEbBeBsK\
\e(B]</a>" 'utf-8-jp-er)))
779 (defun www-ids-insert-chars-including-components* (components
780 &optional ignored-chars products)
782 (setq products (ideograph-find-products components ignored-chars)))
784 (setq len (length products))
788 (sort (copy-list products)
790 (< (char-int a)(char-int b))))
793 (sort (copy-list products)
795 (if (setq as (char-total-strokes a))
796 (if (setq bs (char-total-strokes b))
798 (< (char-int a)(char-int b))
801 (< (char-int a)(char-int b)))))
804 (sort (copy-list products)
806 (if (setq as (char-total-strokes a))
807 (if (setq bs (char-total-strokes b))
809 (ideograph-char< a b)
812 (ideograph-char< a b))))
814 (unless (memq c ignored-chars)
815 (setq is (char-feature c 'ideographic-structure))
817 (www-ids-find-format-line c is)
819 (www-ids-insert-chars-including-components*
820 (char-to-string c) (cons c ignored-chars)))
827 (defun www-ids-insert-chars-including-components (components
828 &optional ignored-chars)
829 (let ((products (ideograph-find-products components ignored-chars))
830 is as bs len ignore-children)
831 (setq len (length products))
833 (setq ignore-children t)
835 (encode-coding-string
836 "<p>
\e$B7k2L$,B?$9$.$k$?$a!":F5"E*8!:w$r>JN,$7$^$7$?!#
\e(B</p>"
840 (www-ids-find-format-char c))
843 (www-ids-insert-chars-including-components* components ignored-chars products)))
844 (dolist (c ignored-chars)
845 (dolist (vc (char-component-variants c))
846 (unless (memq vc ignored-chars)
847 (when (setq is (get-char-attribute vc 'ideographic-structure))
849 (www-ids-find-format-line vc is)
851 (www-ids-insert-chars-including-components*
853 (cons vc ignored-chars)))))))
854 (setq products (ideograph-find-products-with-variants components ignored-chars))
855 (setq len (length products))
857 (setq ignore-children t)
859 (encode-coding-string
860 "<p>
\e$B7k2L$,B?$9$.$k$?$a!"4XO";z$N:F5"E*8!:w$r>JN,$7$^$7$?!#
\e(B</p>"
864 (www-ids-find-format-char c))
865 (dolist (c (sort (copy-tree products)
867 (if (setq as (char-total-strokes a))
868 (if (setq bs (char-total-strokes b))
870 (ideograph-char< a b)
873 (ideograph-char< a b)))))
874 (unless (memq c ignored-chars)
875 (setq is (get-char-attribute c 'ideographic-structure))
877 (www-ids-find-format-line c is)
878 (unless ignore-children
880 (www-ids-insert-chars-including-components*
882 (cons c ignored-chars))))
888 (defun www-batch-ids-find ()
889 (let ((components (car command-line-args-left))
890 (coded-charset-entity-reference-alist
892 '(=cns11643-1 "C1-" 4 X)
893 '(=cns11643-2 "C2-" 4 X)
894 '(=cns11643-3 "C3-" 4 X)
895 '(=cns11643-4 "C4-" 4 X)
896 '(=cns11643-5 "C5-" 4 X)
897 '(=cns11643-6 "C6-" 4 X)
898 '(=cns11643-7 "C7-" 4 X)
900 '(=gb12345 "G1-" 4 X)
901 '(=jis-x0208@1990 "J90-" 4 X)
902 '(=jis-x0212 "JSP-" 4 X)
904 '(=jef-china3 "JC3-" 4 X)
905 '(=jis-x0208@1978 "J78-" 4 X)
906 '(=jis-x0208@1983 "J83-" 4 X)
907 '(=daikanwa "M-" 5 d)
908 coded-charset-entity-reference-alist))
910 (setq command-line-args-left (cdr command-line-args-left))
912 ((stringp components)
913 (if (string-match "^components=" components)
914 (setq components (substring components (match-end 0))))
916 (if (> (length components) 0)
917 (decode-url-string components 'utf-8-er)
921 (setq components nil)
923 (princ "Content-Type: text/html; charset=UTF-8
925 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
926 \"http://www.w3.org/TR/html4/loose.dtd\">
929 <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
930 <title>CHISE IDS Find</title>
931 <link href=\"/css/bootstrap-4.5.0.min.css\" rel=\"stylesheet\">
932 <style type=\"text/css\">
934 .entry { font-size: 36px; }
935 .entry a img { height: 36px; }
936 .ids { font-size: 24px; }
937 .ids a img { height: 24px; }
938 img { vertical-align:middle; }
939 a { text-decoration:none; }
941 li { margin: 0 0 -0.2em; }
944 display: inline-block;
946 .tooltip .tooltiptext {
955 <div class=\"jumbotron jumbotron-fluid mb-0\">
956 <h1 class=\"display-4 text-center\">")
957 (princ (encode-coding-string "CHISE IDS
\e$B4A;z8!:w
\e(B" 'utf-8-jp-er))
960 <p class=\"text-center\">Version ")
961 (princ www-ids-find-version)
962 (princ (format-time-string
963 " (Last-modified: %Y-%m-%d %H:%M:%S)</p>"
966 www-ids-find-ideographic-products-file-name))))
969 <div class=\"container mt-0 mw-100 d-inline-block align-top bg-dark\">
971 <div class=\"input-group mb-3 h3 my-4\">
972 <div class=\"input-group-prepend mw-75 ml-3\">
973 <form action=\"/ids-find\" method=\"GET\">
974 <span class=\"input-group-text\" id=\"basic-addon1\">
976 (princ (encode-coding-string "
\e$BItIJJ8;zNs
\e(B" 'utf-8-jp-er))
979 <input type=\"text\" class=\"form-control\" aria-describedby=\"basic-addon1\" name=\"components\" size=\"30\" maxlength=\"256\" value=\"")
980 (if (> (length components) 0)
981 (princ (encode-coding-string components 'utf-8-er)))
983 <input class=\"mr-3\" type=\"submit\" value=\"")
984 (princ (encode-coding-string "
\e$B8!:w3+;O
\e(B" 'utf-8-jp-er))
991 (unless (file-newer-than-file-p
992 www-ids-find-ideographic-products-file-name
993 (locate-file (car command-line-args) exec-path))
994 (princ (encode-coding-string "<hr>
996 \e$B8=:_!"%7%9%F%`$N99?7:n6HCf$G$9!#$7$P$i$/$*BT$A$/$@$5$$!#
\e(B
999 ;; (setq components nil)
1003 (princ "<div class=\"container\">
1005 ;; (map-char-attribute
1007 ;; (when (every (lambda (p)
1008 ;; (ideographic-structure-member p v))
1010 ;; (princ (encode-coding-string
1011 ;; (ids-find-format-line c v)
1016 ;; 'ideographic-structure)
1017 (when (= (length components) 1)
1018 (www-ids-find-format-line (aref components 0)
1019 (char-feature (aref components 0)
1020 'ideographic-structure)))
1021 ;; (dolist (c (ideographic-products-find components))
1022 ;; (setq is (char-feature c 'ideographic-structure))
1023 ;; ;; to avoid problems caused by wrong indexes
1024 ;; (when (every (lambda (c)
1025 ;; (ideographic-structure-member c is))
1027 ;; (www-ids-find-format-line c is)))
1029 (www-ids-insert-chars-including-components components)
1030 ;; (princ "</ul>\n")
1034 (princ (encode-coding-string "<div class=\"container mt-4\">
1035 <div class=\"ml-3\">
1037 \e$B;XDj$7$?ItIJ$rA4$F4^$`4A;z$N0lMw$rI=<($7$^$9!#
\e(B
1040 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
1044 (princ (encode-coding-string "
1048 <li><a href=\"http://www.shuiren.org/chuden/toyoshi/syoseki/chise_ids.html\"
1049 >
\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
1050 href=\"http://www.shuiren.org/\">
\e$B?g?MDb
\e(B</a>
\e$B!K$K$h$k2r@b
\e(B
1053 <li><a href=\"http://www.karitsu.org/tools/firefox_plugin.htm\"
1054 >Firefox
\e$BMQ
\e(B plugin</a> by
\e$B=);3M[0lO:$5$s!J
\e(B<a href=\"http://www.karitsu.org/\"
1055 >
\e$B2aN)c7
\e(B</a>
\e$B!K
\e(B
1058 <li><a href=\"http://git.chise.org/gitweb/?p=chise/ids.git;a=blob;f=www/www-ids-find.el\"
1059 >www-ids-find.el (source file (Emacs Lisp part))
1060 <li><a href=\"http://www.chise.org/ids/\"
1061 >
\e$B!V
\e(BCHISE
\e$B4A;z9=B$>pJs%G!<%?%Y!<%9!W
\e(B</a>
1062 <li><a href=\"http://fonts.jp/chise_linkmap/\"
1063 >
\e$B!V
\e(Bchise_linkmap : CHISE
\e$B4A;zO"4D?^!W
\e(B</a> by
\e$B>eCO9(0l$5$s
\e(B
1064 <li><a href=\"http://www.chise.org/\"
1068 <li><a href=\"http://coe21.zinbun.kyoto-u.ac.jp/djvuchar\"
1069 >
\e$B!VBsK\J8;z%G!<%?%Y!<%9!W
\e(B</a> by
1070 <a href=\"http://coe21.zinbun.kyoto-u.ac.jp/\"
1071 >
\e$B5~ETBg3X
\e(B21
\e$B@$5*
\e(BCOE
\e$B!VEl%"%8%"@$3&$N?MJ8>pJs3X8&5f650i5rE@!W
\e(B</a>
1072 <li><a href=\"http://www.unicode.org/\"
1082 <div class=\"container\">
1084 (princ "<div class=\"ml-0\">
1085 Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2015, 2016, 2017, 2020 <a href=\"http://kanji.zinbun.kyoto-u.ac.jp/~tomo/\"
1086 >MORIOKA Tomohiko</a></div>")
1090 href=\"http://www.chise.org/xemacs/\"
1091 >XEmacs CHISE</a> %s.</div>"
1092 (encode-coding-string xemacs-chise-version 'utf-8-jp-er)))