1 ;; -*- coding: utf-8-mcs-er -*-
2 (require 'char-db-util)
3 (require 'chiset-common)
4 ;; (require 'concord-images)
6 (setq file-name-coding-system 'utf-8-mcs-er)
8 (concord-assign-genre 'code-point "/usr/local/var/chise-ipld/db")
9 (concord-assign-genre 'coded-character "/usr/local/var/chise-ipld/db")
10 (concord-assign-genre 'glyph "/usr/local/var/chise-ipld/db")
12 (concord-assign-genre 'image-resource "/usr/local/var/photo/db")
13 (concord-assign-genre 'glyph-image "/usr/local/var/photo/db")
15 (concord-assign-genre 'creator@ruimoku "/usr/local/var/ruimoku/db")
16 (concord-assign-genre 'person-name@ruimoku "/usr/local/var/ruimoku/db")
18 (concord-assign-genre 'journal-volume@ruimoku "/usr/local/var/ruimoku/db")
19 (concord-assign-genre 'article@ruimoku "/usr/local/var/ruimoku/db")
20 (concord-assign-genre 'book@ruimoku "/usr/local/var/ruimoku/db")
22 (concord-assign-genre 'classification@ruimoku "/usr/local/var/ruimoku/db")
23 (concord-assign-genre 'region@ruimoku "/usr/local/var/ruimoku/db")
24 (concord-assign-genre 'era@ruimoku "/usr/local/var/ruimoku/db")
25 (concord-assign-genre 'period@ruimoku "/usr/local/var/ruimoku/db")
26 (concord-assign-genre 'journal@ruimoku "/usr/local/var/ruimoku/db")
27 (concord-assign-genre 'journal-name@ruimoku "/usr/local/var/ruimoku/db")
28 (concord-assign-genre 'publisher@ruimoku "/usr/local/var/ruimoku/db")
29 (concord-assign-genre 'publisher-name@ruimoku "/usr/local/var/ruimoku/db")
31 (mount-char-attribute-table '*instance@ruimoku/bibliography/title)
32 ;; (mount-char-attribute-table '*instance@ruimoku/bibliography/content*note)
34 (concord-assign-genre 'entry@zh-classical "/usr/local/var/kanbun/db")
35 ;; (concord-assign-genre 'morpheme-entry@zh-classical "/usr/local/var/kanbun/db")
36 (concord-assign-genre 'word-class@zh-classical "/usr/local/var/kanbun/db")
37 (concord-assign-genre 'morpheme@zh-classical "/usr/local/var/kanbun/db")
38 (concord-assign-genre 'sentence@zh-classical "/usr/local/var/kanbun/db")
39 ;; (concord-assign-genre 'sentence-entry@zh-classical "/usr/local/var/kanbun/db")
41 (mount-char-attribute-table '*instance@morpheme-entry/zh-classical)
43 (concord-assign-genre 'ud@zh-classical "/usr/local/var/kanbun/db")
46 (concord-assign-genre 'hng-card "/usr/local/var/hng-card/db")
48 (mount-char-attribute-table '->HNG)
49 (mount-char-attribute-table '<-HNG)
50 (mount-char-attribute-table '->HNG@CN/manuscript)
51 (mount-char-attribute-table '<-HNG@CN/manuscript)
52 (mount-char-attribute-table '->HNG@CN/printed)
53 (mount-char-attribute-table '<-HNG@CN/printed)
54 (mount-char-attribute-table '->HNG@JP/manuscript)
55 (mount-char-attribute-table '<-HNG@JP/manuscript)
56 (mount-char-attribute-table '->HNG@JP/printed)
57 (mount-char-attribute-table '<-HNG@JP/printed)
58 (mount-char-attribute-table '->HNG@KR)
59 (mount-char-attribute-table '<-HNG@KR)
60 (mount-char-attribute-table '->HNG@MISC)
61 (mount-char-attribute-table '<-HNG@MISC)
63 (mount-char-attribute-table 'abstract-glyph@iwds-1)
64 (mount-char-attribute-table 'abstract-glyph@iwds-1/confluented)
66 (mount-char-attribute-table '=hdic-tsj-glyph-id)
67 (mount-char-attribute-table '=hdic-syp-entry-id)
68 (mount-char-attribute-table '=hdic-ktb-entry-id)
69 (mount-char-attribute-table 'hdic-tsj-word-id)
70 (mount-char-attribute-table 'hdic-tsj-word)
71 (mount-char-attribute-table 'hdic-tsj-word-description)
72 (mount-char-attribute-table 'hdic-tsj-word-remarks)
73 (mount-char-attribute-table 'hdic-syp-description)
74 (mount-char-attribute-table 'hdic-ktb-description)
75 (mount-char-attribute-table 'hdic-ktb-entry-type)
76 (mount-char-attribute-table 'hdic-ktb-diff)
77 (mount-char-attribute-table 'hdic-ktb-syp-id)
78 (mount-char-attribute-table 'hdic-ktb-yy-id)
79 (mount-char-attribute-table 'hdic-ktb-ndl-pid)
80 (mount-char-attribute-table '<-HDIC-SYP@KTB)
81 (mount-char-attribute-table '->HDIC-SYP@KTB)
83 (mount-char-attribute-table 'sound@fanqie)
85 (defvar est-hide-cgi-mode nil)
86 (defvar est-view-url-prefix "..")
87 (defvar chise-wiki-view-url "view.cgi")
88 (defvar chise-wiki-edit-url "edit.cgi")
90 (defvar chise-wiki-bitmap-glyph-image-url
91 "https://image.chise.org/glyphs")
93 (defvar chise-wiki-legacy-bitmap-glyphs-url
94 "https://www.chise.org/glyphs")
96 (defvar chise-wiki-hng-bitmap-glyphs-url
97 "https://image.hng-data.org/glyphs/HNG")
99 (defvar chise-wiki-daijiten-bitmap-glyphs-url
100 "https://image.hng-data.org/glyphs/daijiten")
102 (defvar chise-wiki-glyphwiki-glyph-image-url
103 "https://glyphwiki.org/glyph")
105 (defvar chise-wiki-glyph-cgi-url
106 "https://www.chise.org/chisewiki/glyph.cgi")
108 (defvar chise-wiki-displayed-features nil)
110 (defvar est-coded-charset-priority-list
112 =cns11643-1 =cns11643-2 =cns11643-3
113 =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7
115 =jis-x0208 =jis-x0208@1990
120 =jis-x0213-1@2000 =jis-x0213-1@2004
121 =jis-x0208@1983 =jis-x0208@1978
122 =zinbun-oracle =>zinbun-oracle
126 ==jis-x0208 ==jis-x0213-1 ==jis-x0213-2
127 =>>jis-x0208 =>>jis-x0213-1 =>>jis-x0213-2
129 =+>jis-x0208 =+>jis-x0213-1 =+>jis-x0213-2
132 =>jis-x0208 =>jis-x0213-1
134 =>ucs@iso =>ucs@unicode
135 =>ucs@jis =>ucs@cns =>ucs@ks
136 =+>ucs@iso =+>ucs@unicode
137 =>>ucs@iso =>>ucs@unicode
138 =>>ucs@jis =>>ucs@cns =>>ucs@ks
139 ==ucs@iso ==ucs@unicode
140 ==ucs@jis ==ucs@cns ==ucs@ks
185 ===cns11643-1 ===cns11643-2 ===cns11643-3
186 ===cns11643-4 ===cns11643-5 ===cns11643-6 ===cns11643-7
189 (defvar est-coded-charset-entity-reference-alist
193 '(=hanyo-denshi/ja "HD-JA-" 4 X)
194 '(=hanyo-denshi/jb "HD-JB-" 4 X)
195 '(=hanyo-denshi/jc "HD-JC-" 4 X)
196 '(=hanyo-denshi/jd "HD-JD-" 4 X)
197 '(=hanyo-denshi/ft "HD-FT-" 4 X)
198 '(=hanyo-denshi/ia "HD-IA-" 4 X)
199 '(=hanyo-denshi/ib "HD-IB-" 4 X)
200 '(=hanyo-denshi/hg "HD-HG-" 4 X)
201 '(=hanyo-denshi/ip "HD-IP-" 4 X)
202 '(=hanyo-denshi/jt "HD-JT-" 4 X)
203 '(=hanyo-denshi/ks "HD-KS-" 6 d)
204 '(=>>hanyo-denshi/ja "G-HD-JA-" 4 X)
205 '(=>>hanyo-denshi/jb "G-HD-JB-" 4 X)
206 '(=>>hanyo-denshi/jc "G-HD-JC-" 4 X)
207 '(=>>hanyo-denshi/jd "G-HD-JD-" 4 X)
208 '(=>>hanyo-denshi/ft "G-HD-FT-" 4 X)
209 '(=>>hanyo-denshi/ia "G-HD-IA-" 4 X)
210 '(=>>hanyo-denshi/ib "G-HD-IB-" 4 X)
211 '(=>>hanyo-denshi/hg "G-HD-HG-" 4 X)
212 '(=>>hanyo-denshi/ip "G-HD-IP-" 4 X)
213 '(=>>hanyo-denshi/jt "G-HD-JT-" 4 X)
214 '(=>>hanyo-denshi/ks "G-HD-KS-" 6 d)
216 '(==hanyo-denshi/ja "g2-HD-JA-" 4 X)
217 '(==hanyo-denshi/jb "g2-HD-JB-" 4 X)
218 '(==hanyo-denshi/jc "g2-HD-JC-" 4 X)
219 '(==hanyo-denshi/jd "g2-HD-JD-" 4 X)
220 '(==hanyo-denshi/ft "g2-HD-FT-" 4 X)
221 '(==hanyo-denshi/ia "g2-HD-IA-" 4 X)
222 '(==hanyo-denshi/ib "g2-HD-IB-" 4 X)
223 '(==hanyo-denshi/hg "g2-HD-HG-" 4 X)
224 '(==hanyo-denshi/ip "g2-HD-IP-" 4 X)
225 '(==hanyo-denshi/jt "g2-HD-JT-" 4 X)
226 '(==hanyo-denshi/ks "g2-HD-KS-" 6 d)
227 '(==daijiten "g2-DJT-" 5 d)
228 '(=cns11643-1 "C1-" 4 X)
229 '(=cns11643-2 "C2-" 4 X)
230 '(=cns11643-3 "C3-" 4 X)
231 '(=cns11643-4 "C4-" 4 X)
232 '(=cns11643-5 "C5-" 4 X)
233 '(=cns11643-6 "C6-" 4 X)
234 '(=cns11643-7 "C7-" 4 X)
235 '(=adobe-japan1-6 "AJ1-" 5 d)
236 '(=big5-cdp "CDP-" 4 X)
237 '(=>big5-cdp "A-CDP-" 4 X)
239 '(=gb12345 "G1-" 4 X)
240 '(=jis-x0208@1990 "J90-" 4 X)
241 '(=jis-x0212 "JSP-" 4 X)
243 '(=jis-x0208@1997 "J97-" 4 X)
244 '(=jis-x0208@1978 "J78-" 4 X)
245 '(=jis-x0208@1983 "J83-" 4 X)
246 '(=ruimoku-v6 "RUI6-" 4 X)
247 '(=zinbun-oracle "ZOB-" 4 d)
248 '(=daijiten "DJT-" 5 d)
249 '(=>ucs-itaiji-001 "A-U-i001+" 4 X)
250 '(=>ucs-itaiji-002 "A-U-i002+" 4 X)
251 '(=>ucs-itaiji-003 "A-U-i003+" 4 X)
252 '(=>ucs-itaiji-004 "A-U-i004+" 4 X)
253 '(=>ucs-itaiji-005 "A-U-i005+" 4 X)
254 '(=>ucs-itaiji-006 "A-U-i006+" 4 X)
255 '(=>ucs-itaiji-007 "A-U-i007+" 4 X)
256 '(=>ucs-itaiji-008 "A-U-i008+" 4 X)
257 '(=>ucs-itaiji-009 "A-U-i009+" 4 X)
258 '(=>ucs-itaiji-010 "A-U-i010+" 4 X)
259 '(=>ucs-itaiji-011 "A-U-i011+" 4 X)
260 '(=>ucs-itaiji-001@iwds-1 "A-IWDSU-i001+" 4 X)
261 '(=>ucs-itaiji-002@iwds-1 "A-IWDSU-i002+" 4 X)
262 '(=>ucs-itaiji-003@iwds-1 "A-IWDSU-i003+" 4 X)
263 '(=>ucs-itaiji-006@iwds-1 "A-IWDSU-i006+" 4 X)
264 '(=jef-china3 "JC3-" 4 X)
265 '(=ucs@unicode "UU+" 4 X)
266 '(=ucs@JP/hanazono "hanaJU+" 4 X)
267 '(==cns11643-1 "R-C1-" 4 X)
268 '(==cns11643-2 "R-C2-" 4 X)
269 '(==cns11643-3 "R-C3-" 4 X)
270 '(==cns11643-4 "R-C4-" 4 X)
271 '(==cns11643-5 "R-C5-" 4 X)
272 '(==cns11643-6 "R-C6-" 4 X)
273 '(==cns11643-7 "R-C7-" 4 X)
274 '(=hanziku-1 "HZK01-" 4 X)
275 '(=hanziku-2 "HZK02-" 4 X)
276 '(=hanziku-3 "HZK03-" 4 X)
277 '(=hanziku-4 "HZK04-" 4 X)
278 '(=hanziku-5 "HZK05-" 4 X)
279 '(=hanziku-6 "HZK06-" 4 X)
280 '(=hanziku-7 "HZK07-" 4 X)
281 '(=hanziku-8 "HZK08-" 4 X)
282 '(=hanziku-9 "HZK09-" 4 X)
283 '(=hanziku-10 "HZK10-" 4 X)
284 '(=hanziku-11 "HZK11-" 4 X)
285 '(=hanziku-12 "HZK12-" 4 X)
286 '(==>daijiten "A2-DJT-" 5 d)
289 '(=daikanwa "M-" 5 d)
290 '(=>>daikanwa "G-M-" 5 d)
291 '(===ucs@ks "R-KU+" 4 X)
292 coded-charset-entity-reference-alist))
294 (defun decode-uri-string (string &optional coding-system)
295 (if (> (length string) 0)
299 (mapconcat (lambda (char)
302 (char-to-string char)))
304 (while (string-match "%\\([0-9A-F][0-9A-F]\\)" string i)
305 (setq dest (concat dest
306 (substring string i (match-beginning 0))
309 (string-to-int (match-string 1 string) 16))))
311 (decode-coding-string
312 (concat dest (substring string i))
315 (defun www-feature-type (feature-name)
316 (or (char-feature-property feature-name 'type)
317 (let ((str (symbol-name feature-name)))
319 ((string-match "\\*note\\(@[^*]+\\)?$" str)
321 ((string-match "\\*sources\\(@[^*]+\\)?$" str)
323 ((string-match "\\*" str)
325 ((string-match "^\\(->\\|<-\\)" str)
327 ((string-match "^ideographic-structure\\(@\\|$\\)" str)
331 (defun www-feature-format (feature-name)
332 (or (char-feature-property feature-name 'presentation-format)
333 (char-feature-property feature-name 'format)
335 (setq fn feature-name)
336 (while (and (setq parent (char-feature-name-parent fn))
338 (char-feature-property
342 '((name) " : " (value))))
344 (defun www-feature-value-format (feature-name)
345 (or (char-feature-property feature-name 'value-presentation-format)
346 (char-feature-property feature-name 'value-format)
348 (setq fn feature-name)
349 (while (and (setq parent (char-feature-name-parent fn))
351 (or (char-feature-property
352 parent 'value-presentation-format)
353 (char-feature-property
354 parent 'value-format)))))
357 (let ((type (www-feature-type feature-name)))
358 (cond ((eq type 'relation)
360 ((eq type 'structure)
361 'space-separated-ids)
362 ((eq type 'domain-list)
363 'space-separated-source-list)
367 (if (find-charset feature-name)
368 (if (and (= (charset-dimension feature-name) 2)
369 (= (charset-chars feature-name) 94))
371 " (" (decimal) ") <" (ku-ten) "> " (prev-char) (next-char))
372 '("0x" (HEX) " (" (decimal) ") " (prev-char) (next-char))))
375 (defun char-feature-name-at-domain (feature-name domain)
377 (let ((name (symbol-name feature-name)))
379 ((string-match "@[^*]+$" name)
380 (intern (format "%s/%s" name domain))
383 (intern (format "%s@%s" name domain))
387 (defun char-feature-name-parent (feature-name)
388 (let ((name (symbol-name feature-name)))
389 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
390 (intern (substring name 0 (car (last (match-data) 2)))))))
392 (defun char-feature-name-domain (feature-name)
393 (let ((name (symbol-name feature-name)))
394 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
395 (intern (substring name (1+ (match-beginning 0)))))))
397 (defun char-feature-name-sans-versions (feature)
398 (let ((feature-name (symbol-name feature)))
399 (if (string-match "[@/]\\$rev=latest$" feature-name)
400 (intern (substring feature-name 0 (match-beginning 0)))
403 (defun est-object-genre (object)
404 (if (characterp object)
406 (concord-object-genre object)))
408 (defun www-get-feature-value (object feature)
409 (let ((latest-feature (char-feature-name-at-domain feature '$rev=latest)))
412 (mount-char-attribute-table latest-feature)
413 (or (char-feature object latest-feature)
414 (char-feature object feature))
417 (or (condition-case nil
418 (concord-object-get object latest-feature)
421 (concord-object-get object feature)
425 (defun get-previous-code-point (ccs code)
426 (let ((chars (charset-chars ccs))
427 (dim (charset-dimension ccs))
429 mask byte-min byte-max
452 (setq bytes (make-vector dim 0))
454 (aset bytes i (logand (lsh code (* i -8)) mask))
457 (while (and (< i dim)
459 (aset bytes i (1- (aref bytes i)))
460 (< (aref bytes i) byte-min)))
461 (aset bytes i byte-max)
464 (setq dest (aref bytes 0)
467 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
471 (defun get-next-code-point (ccs code)
472 (let ((chars (charset-chars ccs))
473 (dim (charset-dimension ccs))
475 mask byte-min byte-max
498 (setq bytes (make-vector dim 0))
500 (aset bytes i (logand (lsh code (* i -8)) mask))
503 (while (and (< i dim)
505 (aset bytes i (1+ (aref bytes i)))
506 (> (aref bytes i) byte-max)))
507 (aset bytes i byte-min)
510 (setq dest (aref bytes 0)
513 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
517 (defun find-previous-defined-code-point (ccs code)
518 (let ((i (get-previous-code-point ccs code))
521 ((eq ccs '=jis-x0208)
522 (setq ccs '=jis-x0208@1990))
523 ((eq ccs '=jis-x0213-1)
524 (setq ccs '=jis-x0213-1@2004)))
527 (null (setq char (decode-char ccs i
528 (unless (eq ccs '=ucs)
530 (setq i (get-previous-code-point ccs i)))
533 (defun find-next-defined-code-point (ccs code)
534 (let ((i (get-next-code-point ccs code))
536 (setq max (+ code 1000))
538 ((eq ccs '=jis-x0208)
539 (setq ccs '=jis-x0208@1990))
540 ((eq ccs '=jis-x0213-1)
541 (setq ccs '=jis-x0213-1@2004)))
544 (null (setq char (decode-char ccs i
545 (unless (eq ccs '=ucs)
547 (setq i (get-next-code-point ccs i)))
551 ;;; @ URI representation
554 ;; (defun est-uri-decode-feature-name-body (uri-feature)
555 ;; (let ((len (length uri-feature))
562 ;; (if (eq (aref uri-feature i) ?\.)
563 ;; (if (and (< (+ i 2) len)
564 ;; (eq (aref uri-feature (+ i 2)) ?\.))
567 ;; ((eq (setq ch (aref uri-feature (1+ i))) ?\.)
574 ;; (substring uri-feature i (+ i 3))
580 ;; (char-to-string (aref uri-feature i))
581 ;; (setq i (1+ i)))))))
584 ;; (defun est-uri-encode-feature-name-body (feature)
585 ;; (mapconcat (lambda (c)
592 ;; (t (char-to-string c))))
595 ;; (defun www-uri-decode-feature-name (uri-feature)
597 ;; (setq uri-feature (decode-uri-string uri-feature 'utf-8-mcs-er))
599 ;; ((string-match "^from\\." uri-feature)
600 ;; (intern (format "<-%s"
601 ;; (est-uri-decode-feature-name-body
602 ;; (substring uri-feature (match-end 0)))))
604 ;; ((string-match "^to\\." uri-feature)
605 ;; (intern (format "->%s"
606 ;; (est-uri-decode-feature-name-body
607 ;; (substring uri-feature (match-end 0)))))
609 ;; ((string-match "^rep\\." uri-feature)
610 ;; (intern (format "=%s"
611 ;; (est-uri-decode-feature-name-body
612 ;; (substring uri-feature (match-end 0)))))
614 ;; ((string-match "^rep[2i]\\." uri-feature)
615 ;; (intern (format "===%s"
616 ;; (est-uri-decode-feature-name-body
617 ;; (substring uri-feature (match-end 0)))))
619 ;; ((string-match "^g\\." uri-feature)
620 ;; (intern (format "=>>%s"
621 ;; (est-uri-decode-feature-name-body
622 ;; (substring uri-feature (match-end 0)))))
624 ;; ((string-match "^g[i2]\\." uri-feature)
625 ;; (intern (format "==%s"
626 ;; (est-uri-decode-feature-name-body
627 ;; (substring uri-feature (match-end 0)))))
629 ;; ((string-match "^gi\\([0-9]+\\)\\." uri-feature)
630 ;; (intern (format "=>>%s%s"
631 ;; (make-string (string-to-int
632 ;; (match-string 1 uri-feature))
634 ;; (est-uri-decode-feature-name-body
635 ;; (substring uri-feature (match-end 0)))))
637 ;; ((string-match "^o\\." uri-feature)
638 ;; (intern (format "=+>%s"
639 ;; (est-uri-decode-feature-name-body
640 ;; (substring uri-feature (match-end 0)))))
642 ;; ((string-match "^a\\." uri-feature)
643 ;; (intern (format "=>%s"
644 ;; (est-uri-decode-feature-name-body
645 ;; (substring uri-feature (match-end 0)))))
647 ;; ((string-match "^a\\([0-9]+\\)\\." uri-feature)
648 ;; (intern (format "%s>%s"
649 ;; (make-string (string-to-int
650 ;; (match-string 1 uri-feature))
652 ;; (est-uri-decode-feature-name-body
653 ;; (substring uri-feature (match-end 0)))))
655 ;; ((and (setq uri-feature (est-uri-decode-feature-name-body uri-feature))
656 ;; (setq feature (intern (format "=>%s" uri-feature)))
657 ;; (find-charset feature))
659 ;; ((and (setq feature (intern (format "=>>%s" uri-feature)))
660 ;; (find-charset feature))
662 ;; ((and (setq feature (intern (format "=>>>%s" uri-feature)))
663 ;; (find-charset feature))
665 ;; ((and (setq feature (intern (format "=%s" uri-feature)))
666 ;; (find-charset feature))
668 ;; (t (intern uri-feature)))))
670 ;; (defun www-uri-encode-feature-name (feature-name)
671 ;; (setq feature-name (symbol-name feature-name))
673 ;; ((string-match "^=\\+>\\([^=>]+\\)" feature-name)
675 ;; (est-uri-encode-feature-name-body
676 ;; (substring feature-name (match-beginning 1))))
678 ;; ((string-match "^=\\([^=>]+\\)" feature-name)
680 ;; (est-uri-encode-feature-name-body
681 ;; (substring feature-name (match-beginning 1))))
683 ;; ((string-match "^==\\([^=>]+\\)" feature-name)
685 ;; (est-uri-encode-feature-name-body
686 ;; (substring feature-name (match-beginning 1))))
688 ;; ((string-match "^===\\([^=>]+\\)" feature-name)
690 ;; (est-uri-encode-feature-name-body
691 ;; (substring feature-name (match-beginning 1))))
693 ;; ((string-match "^=>>\\([^=>]+\\)" feature-name)
695 ;; (est-uri-encode-feature-name-body
696 ;; (substring feature-name (match-beginning 1))))
698 ;; ((string-match "^=>>>\\([^=>]+\\)" feature-name)
700 ;; (est-uri-encode-feature-name-body
701 ;; (substring feature-name (match-beginning 1))))
703 ;; ((string-match "^=>>\\(>+\\)" feature-name)
705 ;; (length (match-string 1 feature-name))
706 ;; (est-uri-encode-feature-name-body
707 ;; (substring feature-name (match-end 1))))
709 ;; ((string-match "^=>\\([^=>]+\\)" feature-name)
711 ;; (est-uri-encode-feature-name-body
712 ;; (substring feature-name (match-beginning 1))))
714 ;; ((string-match "^\\(=+\\)>" feature-name)
716 ;; (length (match-string 1 feature-name))
717 ;; (est-uri-encode-feature-name-body
718 ;; (substring feature-name (match-end 0))))
720 ;; ((string-match "^->" feature-name)
722 ;; (est-uri-encode-feature-name-body
723 ;; (substring feature-name (match-end 0))))
725 ;; ((string-match "^<-" feature-name)
727 ;; (est-uri-encode-feature-name-body
728 ;; (substring feature-name (match-end 0))))
730 ;; (t (est-uri-encode-feature-name-body feature-name))))
732 (defun www-uri-make-feature-name-url (uri-genre uri-feature-name uri-object)
733 (if est-hide-cgi-mode
734 (format "../feature/%s&%s/%s"
735 uri-feature-name uri-genre uri-object)
736 (format "%s?feature=%s&%s=%s"
737 chise-wiki-view-url uri-feature-name uri-genre uri-object)))
739 (defun www-uri-decode-object (genre char-rep)
742 ((string-match (if est-hide-cgi-mode
743 "\\(%3D\\|=\\|%3A\\|:\\)"
744 "\\(%3A\\|:\\)") char-rep)
745 (setq ccs (substring char-rep 0 (match-beginning 0))
746 cpos (substring char-rep (match-end 0)))
747 (setq ccs (www-uri-decode-feature-name ccs))
748 (setq cpos (est-uri-decode-feature-name-body cpos))
750 ((string-match "^0x" cpos)
752 (string-to-number (substring cpos (match-end 0)) 16))
755 (setq cpos (car (read-from-string
757 cpos file-name-coding-system))))
759 (if (and (eq genre 'character)
761 (decode-char ccs cpos)
762 (concord-decode-object ccs cpos genre))
765 (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er))
767 ((eq genre 'character)
768 (when (= (length char-rep) 1)
772 (concord-decode-object
773 '=id (www-uri-decode-feature-name char-rep) 'feature)
776 (concord-decode-object
777 '=id (car (read-from-string char-rep)) genre)
780 (defun www-uri-encode-object (object)
781 (if (characterp object)
782 (if (encode-char object '=ucs)
785 (format "%%%02X" byte))
786 (encode-coding-string (char-to-string object) 'utf-8-mcs-er)
788 (let ((ccs-list est-coded-charset-priority-list)
791 (setq ccs (pop ccs-list))
792 (not (setq ret (encode-char object ccs 'defined-only)))))
794 (format (if est-hide-cgi-mode
797 (www-uri-encode-feature-name ccs)
799 ((and (setq ccs (car (split-char object)))
800 (setq ret (encode-char object ccs)))
801 (format (if est-hide-cgi-mode
804 (www-uri-encode-feature-name ccs)
807 (format (if est-hide-cgi-mode
808 "system-char-id=0x%X"
809 "system-char-id:0x%X")
810 (encode-char object 'system-char-id))
812 (format (if est-hide-cgi-mode
815 (www-uri-encode-feature-name
816 (concord-object-id object)))))
818 (defun est-format-object (object &optional readable)
819 (if (characterp object)
820 (char-to-string object)
821 (let ((ret (or (if readable
822 (or (concord-object-get object 'name)
823 (concord-object-get object '=name)
824 (concord-object-get object 'title)
825 (concord-object-get object '=title)))
826 (concord-object-id object))))
829 (defun www-uri-make-object-url (object &optional uri-object)
830 (if est-hide-cgi-mode
833 (est-object-genre object)
835 (www-uri-encode-object object)))
838 (est-object-genre object)
840 (www-uri-encode-object object)))))
843 ;;; @ Feature name presentation
846 (defun www-format-feature-name-default (feature-name)
850 (symbol-name feature-name)
854 (defun www-format-feature-name-as-metadata (feature-name &optional lang)
855 (let ((str (symbol-name feature-name))
858 ((string-match "\\*[^*]+$" str)
859 (setq base (substring str 0 (match-beginning 0))
860 meta (substring str (match-beginning 0)))
861 (concat (www-format-feature-name* (intern base) lang)
864 (www-format-feature-name-default feature-name)
867 (defun www-format-feature-name-as-rel-to (feature-name)
868 (concat "\u2192" (substring (symbol-name feature-name) 2)))
870 (defun www-format-feature-name-as-rel-from (feature-name)
871 (concat "\u2190" (substring (symbol-name feature-name) 2)))
873 (defun www-format-feature-name-as-CCS (feature-name)
876 (symbol-name feature-name)
878 (dest (upcase (pop rest))))
879 (when (string-match "^=+>*" dest)
880 (setq dest (concat (substring dest 0 (match-end 0))
882 (substring dest (match-end 0)))))
886 (setq dest (concat dest " " (upcase (pop rest)))))
887 (if (string-match "^[0-9]+$" (car rest))
888 (concat dest "-" (car rest))
889 (concat dest " " (upcase (car rest))))
893 (defun www-format-feature-name* (feature-name &optional lang)
894 (let (name fn parent ret)
897 (char-feature-property
899 (intern (format "name@%s" lang))))
900 (char-feature-property
901 feature-name 'name)))
902 ((and (setq name (symbol-name feature-name))
903 (string-match "\\*" name))
904 (www-format-feature-name-as-metadata feature-name lang))
906 (setq fn feature-name)
907 (while (and (setq parent (char-feature-name-parent fn))
910 (char-feature-property
912 (intern (format "name@%s" lang))))
913 (char-feature-property
918 (concat ret (substring (symbol-name feature-name)
919 (length (symbol-name parent)))))
920 ((find-charset feature-name)
921 (www-format-feature-name-as-CCS feature-name))
922 ((string-match "^\\(->\\)" name)
923 (www-format-feature-name-as-rel-to feature-name))
924 ((string-match "^\\(<-\\)" name)
925 (www-format-feature-name-as-rel-from feature-name))
927 (www-format-feature-name-default feature-name)
931 (defun www-format-feature-name (feature-name &optional lang)
932 (www-format-encode-string
933 (www-format-feature-name* feature-name lang)))
939 (defvar www-format-char-img-style "vertical-align:bottom;")
941 (defun www-format-encode-string (string &optional without-tags as-body)
944 (let (plane code subcode start end char variants ret rret)
946 (goto-char (point-min))
947 (while (search-forward "&" nil t)
948 (replace-match "&" nil t)))
949 (goto-char (point-min))
950 (while (search-forward "<" nil t)
951 (replace-match "<" nil t))
952 (goto-char (point-min))
953 (while (search-forward ">" nil t)
954 (replace-match ">" nil t))
956 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
957 (let ((coded-charset-entity-reference-alist
958 est-coded-charset-entity-reference-alist))
959 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
961 (goto-char (point-min))
962 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\|R-\\)?CB\\([0-9]+\\);" nil t)
963 (setq code (string-to-int (match-string 2)))
965 (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
968 chise-wiki-legacy-bitmap-glyphs-url
970 www-format-char-img-style)
973 (goto-char (point-min))
974 (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)
975 (setq plane (match-string 2)
976 code (string-to-int (match-string 3) 16))
978 (format "<img alt=\"J%s-%04X\" src=\"%s/JIS-%s/%02d-%02d.gif\"
981 chise-wiki-legacy-bitmap-glyphs-url
984 (- (logand code 255) 32)
985 www-format-char-img-style)
988 (goto-char (point-min))
989 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?J0-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
990 (setq code (string-to-int (match-string 2) 16))
992 (format "<img alt=\"J0-%04X\" src=\"%s/JIS-90/%02d-%02d.gif\"
995 chise-wiki-legacy-bitmap-glyphs-url
997 (- (logand code 255) 32)
998 www-format-char-img-style)
1001 (goto-char (point-min))
1002 (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)
1003 (setq plane (match-string 2)
1004 code (string-to-int (match-string 3) 16))
1006 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%02d%02d.png\"
1009 chise-wiki-legacy-bitmap-glyphs-url
1011 (- (lsh code -8) 32)
1012 (- (logand code 255) 32)
1013 www-format-char-img-style)
1016 (goto-char (point-min))
1017 (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)
1018 (setq plane (match-string 2)
1019 code (string-to-int (match-string 3) 16))
1021 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%04X.png\"
1024 chise-wiki-legacy-bitmap-glyphs-url
1026 www-format-char-img-style)
1029 (goto-char (point-min))
1030 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-KS-\\([0-9]+\\);" nil t)
1031 (setq code (string-to-int (match-string 2)))
1033 (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/KS%06d.png\"
1034 style=\"vertical-align:middle\">"
1036 chise-wiki-legacy-bitmap-glyphs-url
1038 www-format-char-img-style)
1041 (goto-char (point-min))
1042 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-TK-\\([0-9]+\\);" nil t)
1043 (setq code (string-to-int (match-string 2)))
1045 (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/TK%08d.png\"
1046 style=\"vertical-align:middle\">"
1048 chise-wiki-legacy-bitmap-glyphs-url
1050 www-format-char-img-style)
1053 (goto-char (point-min))
1054 (while (re-search-forward "&G\\([01]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
1055 (setq plane (string-to-int (match-string 1))
1056 code (string-to-int (match-string 2) 16))
1058 (format "<img alt=\"GB%d-%04X\" src=\"%s/GB%d/%02d-%02d.gif\"
1061 chise-wiki-legacy-bitmap-glyphs-url
1063 (- (lsh code -8) 32)
1064 (- (logand code 255) 32)
1065 www-format-char-img-style)
1068 (goto-char (point-min))
1069 (while (re-search-forward "&\\(R-\\)?C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
1070 (setq plane (string-to-int (match-string 2))
1071 code (string-to-int (match-string 3) 16))
1073 (format "<img alt=\"CNS%d-%04X\" src=\"%s/CNS%d/%04X.gif\"
1076 chise-wiki-legacy-bitmap-glyphs-url
1078 www-format-char-img-style)
1081 (goto-char (point-min))
1082 (while (re-search-forward "&\\(R-\\)?JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
1083 (setq code (string-to-int (match-string 2) 16))
1085 (format "<img alt=\"JC3-%04X\" src=\"%s/JEF-CHINA3/%04X.png\">"
1086 code chise-wiki-bitmap-glyph-image-url code)
1089 (goto-char (point-min))
1090 (while (re-search-forward "&\\(A-\\)?ZOB-\\([0-9]+\\);" nil t)
1091 (setq code (string-to-int (match-string 2)))
1093 (format "<img alt=\"ZOB-%04d\" src=\"%s/ZOB-1968/%04d.png\"
1094 style=\"vertical-align:middle\">"
1096 chise-wiki-legacy-bitmap-glyphs-url
1098 www-format-char-img-style)
1101 (goto-char (point-min))
1102 (while (re-search-forward "&\\(A2-\\|g2-\\|R-\\)?DJT-\\([0-9]+\\);" nil t)
1103 (setq code (string-to-int (match-string 2)))
1105 (format "<img alt=\"DJT-%05d\" src=\"%s/%05d.png\"
1106 style=\"vertical-align:middle; width: auto; max-height: 60px\">"
1108 chise-wiki-daijiten-bitmap-glyphs-url
1110 www-format-char-img-style)
1113 (goto-char (point-min))
1114 (while (re-search-forward "&SW-JIGUGE\\([45]?\\)-\\([0-9]+\\);" nil t)
1115 (setq subcode (match-string 1)
1116 code (string-to-int (match-string 2)))
1118 (if (string= subcode "")
1122 (format "<div class=\"tooltip\"><img alt=\"SW-JIGUGE%s-%05d\" src=\"%s/ShuoWen/Jiguge%s/%05d.png\"
1123 style=\"vertical-align:middle; width: auto; max-height: 80px\"><span
1124 class=\"tooltiptext\">%s</span></div>"
1126 chise-wiki-legacy-bitmap-glyphs-url
1128 (charset-description
1129 (if (string= subcode "")
1131 (intern (format "===shuowen-jiguge%s" subcode)))))
1134 (goto-char (point-min))
1135 (while (re-search-forward "&HNG\\([0-9]+\\)-\\([0-9][0-9][0-9][0-9]\\)\\([0-9]\\);" nil t)
1136 (setq plane (match-string 1)
1137 code (string-to-int (match-string 2))
1138 subcode (string-to-int (match-string 3)))
1142 (char-to-string (decode-char 'ascii (+ 96 subcode)))))
1145 "<div class=\"tooltip\"><img alt=\"HNG%s-%04d%s\" src=\"%s/%s/%04d%s.png\" style=\"
1146 vertical-align:middle; width: auto; max-height: 60px\"><span
1147 class=\"tooltiptext\">%s</span></div>"
1149 chise-wiki-hng-bitmap-glyphs-url
1151 (charset-description
1152 (car (find (format "HNG%s-" plane)
1153 coded-charset-entity-reference-alist
1154 :test (lambda (key cell)
1155 (string= key (nth 1 cell))))))
1159 (goto-char (point-min))
1160 (while (re-search-forward "&\\(R-\\)?CHISE-HDIC-TSJ\\([0-9A-F]+\\);" nil t)
1161 (setq code (string-to-int (match-string 2) 16))
1162 (setq char (decode-char '===chise-hdic-tsj code))
1163 (when (setq ret (get-char-attribute char '=hdic-tsj-glyph-id))
1166 "<div class=\"tooltip\"><img alt=\"HDIC-TSJ-%s\" src=\"https://viewer.hdic.jp/img/tsj/%s.jpg\" style=\"
1167 vertical-align:middle; width: auto; max-height: 60px\"><span
1168 class=\"tooltiptext\">%s</span></div>"
1170 (charset-description '===chise-hdic-tsj))
1173 (goto-char (point-min))
1174 (while (re-search-forward "&\\(R-\\)?CHISE-HDIC-SYP\\([0-9A-F]+\\);" nil t)
1175 (setq code (string-to-int (match-string 2) 16))
1176 (setq char (decode-char '===chise-hdic-syp code))
1177 (when (setq ret (get-char-attribute char '=hdic-syp-entry-id))
1180 "<div class=\"tooltip\"><img alt=\"HDIC-SYP-%s\" src=\"https://viewer.hdic.jp/img/syp/%s\" style=\"
1181 vertical-align:middle; width: auto; max-height: 60px\"><span
1182 class=\"tooltiptext\">%s</span></div>"
1184 (charset-description '===chise-hdic-syp))
1187 (goto-char (point-min))
1188 (while (re-search-forward "&\\(R-\\)?CHISE-HDIC-KTB\\([0-9A-F]+\\);" nil t)
1189 (setq code (string-to-int (match-string 2) 16))
1190 (setq char (decode-char '===chise-hdic-ktb code))
1191 (when (setq ret (get-char-attribute char '=hdic-ktb-entry-id))
1194 "<div class=\"tooltip\"><img alt=\"HDIC-KTB-%s\" src=\"https://hdic.chise.org/img/ktb/%s.jpg\" style=\"
1195 vertical-align:middle; width: auto; max-height: 60px\"><span
1196 class=\"tooltiptext\">%s</span></div>"
1198 (charset-description '===chise-hdic-ktb))
1201 (goto-char (point-min))
1202 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?AJ1-\\([0-9]+\\);" nil t)
1203 (setq code (string-to-int (match-string 2)))
1205 (format "<img alt=\"AJ1-%05d\" src=\"%s/IVD/AdobeJapan1/CID+%d.png\"
1206 style=\"vertical-align:middle\">"
1208 chise-wiki-legacy-bitmap-glyphs-url
1210 www-format-char-img-style)
1213 (goto-char (point-min))
1214 (while (re-search-forward "&\\(A-\\|o-\\|G-\\|g2-\\|R-\\)?MJ\\([0-9]+\\);" nil t)
1215 (setq code (string-to-int (match-string 2)))
1217 (format "<img alt=\"MJ%06d\" src=\"https://moji.or.jp/mojikibansearch/img/MJ/MJ%06d.png\"
1218 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1221 www-format-char-img-style)
1224 (goto-char (point-min))
1225 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?IU[+-]\\([0-9A-F]+\\);" nil t)
1226 (setq code (string-to-int (match-string 2) 16))
1228 (format "<img alt=\"u%04x\" src=\"%s/u%04x.svg\"
1229 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1231 chise-wiki-glyphwiki-glyph-image-url
1233 www-format-char-img-style)
1236 (goto-char (point-min))
1237 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?KU[+-]\\([0-9A-F]+\\);" nil t)
1238 (setq code (string-to-int (match-string 2) 16))
1240 (format "<img alt=\"u%04x-k\" src=\"%s/u%04x-k.svg\"
1241 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1243 chise-wiki-glyphwiki-glyph-image-url
1245 www-format-char-img-style)
1248 (goto-char (point-min))
1249 (while (re-search-forward "&A-\\(comp\\|cgn\\)U[+-]\\([0-9A-F]+\\);" nil t)
1250 (setq code (string-to-int (match-string 2) 16))
1252 (format "<img alt=\"u%04x\" src=\"%s/u%04x.svg\"
1253 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1255 chise-wiki-glyphwiki-glyph-image-url
1257 www-format-char-img-style)
1260 (goto-char (point-min))
1261 (while (re-search-forward
1262 "&\\(A-\\|g2-\\)?\\(IWDS\\)?U-i\\([0-9]+\\)\\+\\([0-9A-F]+\\);"
1264 (setq plane (string-to-int (match-string 3))
1265 code (string-to-int (match-string 4) 16))
1267 (format "<img alt=\"u%04x-itaiji-%03d\" src=\"%s/u%04x-itaiji-%03d.svg\"
1268 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1271 chise-wiki-glyphwiki-glyph-image-url
1274 www-format-char-img-style)
1277 (goto-char (point-min))
1278 (while (re-search-forward "&A-IWDSU\\+\\([0-9A-F]+\\);" nil t)
1279 (setq code (string-to-int (match-string 1) 16))
1281 (format "<img alt=\"A-IWDSU+%04x\" src=\"%s/u%04x.svg\"
1282 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1284 chise-wiki-glyphwiki-glyph-image-url
1286 www-format-char-img-style)
1289 (goto-char (point-min))
1290 (while (re-search-forward
1291 "&\\(A-\\)?CDP-i\\([0-9]+\\)-\\([0-9A-F]+\\);"
1293 (setq plane (string-to-int (match-string 2))
1294 code (string-to-int (match-string 3) 16))
1296 (format "<img alt=\"cdp-%04x-itaiji-%03d\" src=\"%s/cdp-%04x-itaiji-%03d.svg\"
1297 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1300 chise-wiki-glyphwiki-glyph-image-url
1303 www-format-char-img-style)
1306 (goto-char (point-min))
1307 (while (re-search-forward
1308 "&\\(A-\\)?CDP-v\\([0-9]+\\)-\\([0-9A-F]+\\);"
1310 (setq plane (string-to-int (match-string 2))
1311 code (string-to-int (match-string 3) 16))
1313 (format "<img alt=\"cdp-%04x-var-%03d\" src=\"%s/cdp-%04x-var-%03d.svg\"
1314 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1317 chise-wiki-glyphwiki-glyph-image-url
1320 www-format-char-img-style)
1323 (goto-char (point-min))
1324 (while (re-search-forward
1325 "&\\(A-\\|G-\\|g2-\\|R-\\)?M-\\([0-9]+\\);"
1327 (setq code (string-to-int (match-string 2)))
1329 (format "<img alt=\"dkw-%05d\" src=\"%s/dkw-%05d.svg\"
1330 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1332 chise-wiki-glyphwiki-glyph-image-url
1334 www-format-char-img-style)
1337 (goto-char (point-min))
1338 (while (re-search-forward "&\\(g2-\\)?U-v\\([0-9]+\\)\\+\\([0-9A-F]+\\);" nil t)
1339 (setq plane (string-to-int (match-string 2))
1340 code (string-to-int (match-string 3) 16))
1342 (format "<img alt=\"u%04x-var-%03d\" src=\"%s/u%04x-var-%03d.svg\"
1343 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1346 chise-wiki-glyphwiki-glyph-image-url
1349 www-format-char-img-style)
1352 (goto-char (point-min))
1353 (while (re-search-forward "&\\(A-\\|G-\\|R-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
1354 (setq code (string-to-int (match-string 2)))
1356 (format "<img alt=\"GT-%05d\" src=\"%s?char=GT-%05d\"
1359 chise-wiki-glyph-cgi-url
1361 www-format-char-img-style)
1364 (goto-char (point-min))
1365 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\)?GT-K\\([0-9]+\\);" nil t)
1366 (setq code (string-to-int (match-string 2)))
1368 (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\"
1371 chise-wiki-glyph-cgi-url
1373 www-format-char-img-style)
1376 (goto-char (point-min))
1377 (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
1378 (setq code (string-to-int (match-string 1) 16))
1380 (format "<img alt=\"B-%04X\" src=\"%s?char=B-%04X\"
1383 chise-wiki-glyph-cgi-url
1385 www-format-char-img-style)
1388 (goto-char (point-min))
1389 (while (re-search-forward
1390 "&\\(A-\\|G-\\|g2-\\|R-\\|A-IWDS\\)?CDP-\\([0-9A-F]+\\);" nil t)
1391 (setq code (string-to-int (match-string 2) 16))
1393 (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
1396 chise-wiki-glyph-cgi-url
1398 www-format-char-img-style)
1401 (goto-char (point-min))
1402 (while (re-search-forward
1403 "&\\(I-\\)?HZK\\(0[1-9]\\|1[0-2]\\)-\\([0-9A-F]+\\);" nil t)
1404 (setq plane (match-string 2)
1405 code (string-to-int (match-string 3) 16))
1407 (format "<img alt=\"HZK%s-%04X\" src=\"%s?char=HZK%s-%04X\"
1411 chise-wiki-glyph-cgi-url
1414 www-format-char-img-style)
1417 (goto-char (point-min))
1418 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\|R-\\)?RUI6-\\([0-9A-F]+\\);" nil t)
1419 (setq code (string-to-int (match-string 2) 16))
1421 (format "<img alt=\"RUI6-%04X\" src=\"%s?char=RUI6-%04X\"
1422 style=\"vertical-align:middle\">"
1424 chise-wiki-glyph-cgi-url
1426 www-format-char-img-style)
1429 (goto-char (point-min))
1430 (while (re-search-forward "&hanaJU\\+\\([0-9A-F]+\\);" nil t)
1431 (setq code (string-to-int (match-string 1) 16))
1433 (format "<img alt=\"hanaJU+%04X\" src=\"%s?char=hana-JU+%04X\"
1434 style=\"vertical-align:middle\">"
1436 chise-wiki-glyph-cgi-url
1438 www-format-char-img-style)
1441 (goto-char (point-min))
1442 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\|R-\\)?\\(UU\\+\\|U-\\)\\([0-9A-F]+\\);" nil t)
1443 (setq code (string-to-int (match-string 3) 16))
1445 (format "<img alt=\"UU+%04X\" src=\"https://www.unicode.org/cgi-bin/refglyph?24-%04X\"
1446 style=\"vertical-align:middle\">"
1449 www-format-char-img-style)
1452 (goto-char (point-min))
1453 (while (re-search-forward "&MCS-\\([0-9A-F]+\\);" nil t)
1454 (setq code (string-to-int (match-string 1) 16))
1455 (setq start (match-beginning 0)
1457 (setq char (decode-char 'system-char-id code))
1459 ((and (setq variants
1460 (or (www-get-feature-value char '->subsumptive)
1461 (www-get-feature-value char '->denotational)))
1463 (if (characterp variants)
1464 (setq variants (list variants)))
1465 (while (and variants
1466 (setq ret (www-format-encode-string
1467 (char-to-string (car variants))))
1468 (string-match "&MCS-\\([0-9A-F]+\\);" ret))
1469 (setq variants (cdr variants)))
1471 (unless (string-match "&MCS-\\([0-9A-F]+\\);" ret)
1473 (delete-region start end)
1476 ((setq ret (or (www-get-feature-value char 'ideographic-combination)
1477 (www-get-feature-value char 'ideographic-structure)))
1482 (if (characterp (setq rret (find-char ch)))
1485 (www-format-encode-string
1486 (char-to-string ch) without-tags)
1487 (www-format-encode-string
1488 (format "%S" ch) without-tags)))
1492 (delete-region start end)
1496 ;; (goto-char (point-min))
1497 ;; (while (search-forward ">-" nil t)
1498 ;; (replace-match "&GT-" t 'literal))
1501 (defun www-html-display-text (text)
1505 (goto-char (point-min))
1506 (while (search-forward "<" nil t)
1507 (replace-match "<" nil t))
1508 (goto-char (point-min))
1509 (while (search-forward ">" nil t)
1510 (replace-match ">" nil t))
1511 (goto-char (point-min))
1512 (while (re-search-forward "\\[\\[\\([^]|[]+\\)|\\([^][]+\\)\\]\\]" nil t)
1514 (format "<a href=\"%s\">%s</a>"
1518 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
1519 (goto-char (point-min))
1520 (while (search-forward ">-" nil t)
1521 (replace-match "&GT-" nil t))
1524 (defun www-html-display-paragraph (text)
1526 (www-html-display-text text)
1533 (defvar coded-charset-GlyphWiki-id-alist
1534 '((===adobe-japan1-0 "aj1-" 5 d nil)
1535 (===adobe-japan1-1 "aj1-" 5 d nil)
1536 (===adobe-japan1-2 "aj1-" 5 d nil)
1537 (===adobe-japan1-3 "aj1-" 5 d nil)
1538 (===adobe-japan1-4 "aj1-" 5 d nil)
1539 (===adobe-japan1-5 "aj1-" 5 d nil)
1540 (===adobe-japan1-6 "aj1-" 5 d nil)
1541 (===mj "jmj-" 6 d nil)
1542 (===ucs@jis "u" 4 x "-j")
1543 (===daikanwa "dkw-" 5 d nil)
1544 (===ucs@ks "u" 4 x "-k")
1545 (===jis-x0208@1978 "j78-" 4 x nil)
1546 (==ucs-itaiji-005 "u" 4 x "-itaiji-005")
1547 (=ucs-var-001 "u" 4 x "-var-001")
1548 (=ucs-var-002 "u" 4 x "-var-002")
1549 (=ucs-var-003 "u" 4 x "-var-003")
1550 (=ucs-var-004 "u" 4 x "-var-004")
1551 (=ucs-var-006 "u" 4 x "-var-006")
1552 (=ucs-var-010 "u" 4 x "-var-010")
1553 (=ucs-itaiji-001 "u" 4 x "-itaiji-001")
1554 (=ucs-itaiji-002 "u" 4 x "-itaiji-002")
1555 (=ucs-itaiji-003 "u" 4 x "-itaiji-003")
1556 (=ucs-itaiji-004 "u" 4 x "-itaiji-004")
1557 (=ucs-itaiji-005 "u" 4 x "-itaiji-005")
1558 (=ucs-itaiji-006 "u" 4 x "-itaiji-006")
1559 (=ucs-itaiji-007 "u" 4 x "-itaiji-007")
1560 (=ucs-itaiji-008 "u" 4 x "-itaiji-008")
1561 (=ucs-itaiji-084 "u" 4 x "-itaiji-084")
1562 (=>ucs-itaiji-001 "u" 4 x "-itaiji-001")
1563 (=>ucs-itaiji-002 "u" 4 x "-itaiji-002")
1564 (=>ucs-itaiji-003 "u" 4 x "-itaiji-003")
1565 (=>ucs-itaiji-004 "u" 4 x "-itaiji-004")
1566 (=>ucs-itaiji-005 "u" 4 x "-itaiji-005")
1567 (=>ucs-itaiji-006 "u" 4 x "-itaiji-006")
1568 (=>ucs-itaiji-007 "u" 4 x "-itaiji-007")
1569 (=>ucs-itaiji-008 "u" 4 x "-itaiji-008")
1570 (==adobe-japan1-0 "aj1-" 5 d nil)
1571 (==adobe-japan1-1 "aj1-" 5 d nil)
1572 (==adobe-japan1-2 "aj1-" 5 d nil)
1573 (==adobe-japan1-3 "aj1-" 5 d nil)
1574 (==adobe-japan1-4 "aj1-" 5 d nil)
1575 (==adobe-japan1-5 "aj1-" 5 d nil)
1576 (==adobe-japan1-6 "aj1-" 5 d nil)
1577 (==mj "jmj-" 6 d nil)
1578 (==ucs@jis "u" 4 x "-j")
1579 (==ucs@iso "u" 4 x nil)
1580 ;; (==ucs@cns "u" 4 x "-t")
1581 (==ucs@unicode "u" 4 x "-us")
1582 (==ucs@JP/hanazono "u" 4 x "-jv")
1583 (==gt "gt-" 5 d nil)
1584 (==gt-k "gt-k" 5 d nil)
1585 (==daikanwa "dkw-" 5 d nil)
1586 (==ucs@ks "u" 4 x "-k")
1587 (==jis-x0208@1978 "j78-" 4 x nil)
1588 (==jis-x0208 "j90-" 4 x nil)
1589 (==jis-x0208@1990 "j90-" 4 x nil)
1590 (==jis-x0208@1983 "j83-" 4 x nil)
1591 (==cbeta "cbeta-" 5 d nil)
1592 (=>>hanyo-denshi/ks "koseki-" 6 d nil)
1593 (=>>jis-x0208@1978 "j78-" 4 x nil)
1594 (=>>big5-cdp "cdp-" 4 x nil)
1595 (=>>adobe-japan1-0 "aj1-" 5 d nil)
1596 (=>>adobe-japan1-1 "aj1-" 5 d nil)
1597 (=>>adobe-japan1-2 "aj1-" 5 d nil)
1598 (=>>adobe-japan1-3 "aj1-" 5 d nil)
1599 (=>>adobe-japan1-4 "aj1-" 5 d nil)
1600 (=>>adobe-japan1-5 "aj1-" 5 d nil)
1601 (=>>adobe-japan1-6 "aj1-" 5 d nil)
1602 (=>>jis-x0208 "j90-" 4 x nil)
1603 (=>>jis-x0208@1990 "j90-" 4 x nil)
1604 (=>>jis-x0208@1983 "j83-" 4 x nil)
1605 (=>>daikanwa "dkw-" 5 d nil)
1606 (=adobe-japan1-0 "aj1-" 5 d nil)
1607 (=adobe-japan1-1 "aj1-" 5 d nil)
1608 (=adobe-japan1-2 "aj1-" 5 d nil)
1609 (=adobe-japan1-3 "aj1-" 5 d nil)
1610 (=adobe-japan1-4 "aj1-" 5 d nil)
1611 (=adobe-japan1-5 "aj1-" 5 d nil)
1612 (=adobe-japan1-6 "aj1-" 5 d nil)
1613 (=hanyo-denshi/ks "koseki-" 6 d nil)
1614 (=mj "jmj-" 6 d nil)
1615 (=decomposition@cid)
1616 (=decomposition@hanyo-denshi)
1617 (=koseki "koseki-" 6 d nil)
1618 (=hanyo-denshi/tk "toki-" 8 d nil)
1619 (=ucs@jis "u" 4 x "-j")
1620 ;; (=ucs@cns "u" 4 x "-t")
1621 (=ucs@ks "u" 4 x "-k")
1622 (=ucs@JP "u" 4 x "-jv")
1623 (=ucs@JP/hanazono "u" 4 x "-jv")
1624 (=ucs@gb "u" 4 x "-g")
1625 (=big5-cdp "cdp-" 4 x nil)
1626 (=>big5-cdp "cdp-" 4 x nil)
1627 (=+>big5-cdp "cdp-" 4 x nil)
1628 (=>big5-cdp@iwds-1 "cdp-" 4 x nil)
1629 (=cbeta "cbeta-" 5 d nil)
1630 (=>cbeta "cbeta-" 5 d nil)
1631 (=big5-cdp-var-001 "cdp-" 4 x "-var-001")
1632 (=big5-cdp-var-003 "cdp-" 4 x "-var-003")
1633 (=big5-cdp-var-005 "cdp-" 4 x "-var-005")
1634 (=big5-cdp-itaiji-001 "cdp-" 4 x "-itaiji-001")
1635 (=big5-cdp-itaiji-002 "cdp-" 4 x "-itaiji-002")
1636 (=big5-cdp-itaiji-003 "cdp-" 4 x "-itaiji-003")
1637 (=>big5-cdp-itaiji-001 "cdp-" 4 x "-itaiji-001")
1638 (=>big5-cdp-itaiji-002 "cdp-" 4 x "-itaiji-002")
1639 (=>big5-cdp-itaiji-003 "cdp-" 4 x "-itaiji-003")
1640 (=jef-china3 "jc3-" 4 x nil)
1641 (=jis-x0212 "jsp-" 4 x nil)
1642 (=jis-x0213-1@2000 "jx1-2000-" 4 x nil)
1643 (=jis-x0213-1@2004 "jx1-2004-" 4 x nil)
1644 (=jis-x0213-2 "jx2-" 4 x nil)
1646 (=gt-k "gt-k" 5 d nil)
1647 (=>gt-k "gt-k" 5 d nil)
1648 (=daikanwa "dkw-" 5 d nil)
1649 (=ruimoku-v6 "rui6-" 4 x nil)
1650 (=>ruimoku-v6 "rui6-" 4 x nil)
1651 (=ucs@iso "u" 4 x "-u")
1652 (=ucs@unicode "u" 4 x "-us")
1653 (=jis-x0208@1978/1pr "j78-" 4 x nil)
1654 (=jis-x0208@1978/-4pr "j78-" 4 x nil)
1655 (=jis-x0208@1978 "j78-" 4 x nil)
1656 (=+>jis-x0208@1978 "j78-" 4 x nil)
1657 (=+>jis-x0208 "j90-" 4 x nil)
1658 (=+>jis-x0208@1990 "j90-" 4 x nil)
1659 (=+>jis-x0208@1983 "j83-" 4 x nil)
1661 (=big5 "b-" 4 x nil)
1662 (=ks-x1001 "k0-" 4 x nil)
1663 ;; (=cns11643-1 "c1-" 4 x nil)
1664 ;; (=cns11643-2 "c2-" 4 x nil)
1665 ;; (=cns11643-3 "c3-" 4 x nil)
1666 ;; (=cns11643-4 "c4-" 4 x nil)
1667 ;; (=cns11643-5 "c5-" 4 x nil)
1668 ;; (=cns11643-6 "c6-" 4 x nil)
1669 ;; (=cns11643-7 "c7-" 4 x nil)
1670 (=jis-x0208 "j90-" 4 x nil)
1671 (=jis-x0208@1990 "j90-" 4 x nil)
1672 (=jis-x0208@1983 "j83-" 4 x nil)
1675 (defun char-GlyphWiki-id (char)
1676 (let ((rest coded-charset-GlyphWiki-id-alist)
1679 (setq spec (pop rest))
1680 (null (setq ret (get-char-attribute char (car spec))))))
1684 (mapconcat #'char-GlyphWiki-id ret "-"))
1685 (and (memq (car spec) '(=ucs@unicode '=ucs@iso))
1687 ((and (or (encode-char char '=jis-x0208@1990)
1688 (encode-char char '=jis-x0212)
1689 (encode-char char '=jis-x0213-1)
1690 (encode-char char '=jis-x0213-2))
1691 (setq code (encode-char char '=ucs@jis)))
1692 (format "u%04x-j" code)
1694 ((and (or (encode-char char '=gb2312)
1695 (encode-char char '=gb12345))
1696 (setq code (encode-char char '=ucs@gb)))
1697 (format "u%04x-g" code)
1699 ;; ((and (or (encode-char char '=cns11643-1)
1700 ;; (encode-char char '=cns11643-2)
1701 ;; (encode-char char '=cns11643-3)
1702 ;; (encode-char char '=cns11643-4)
1703 ;; (encode-char char '=cns11643-5)
1704 ;; (encode-char char '=cns11643-6)
1705 ;; (encode-char char '=cns11643-7))
1706 ;; (setq code (encode-char char '=ucs@cns)))
1707 ;; (format "u%04x-t" code)
1709 ((and (encode-char char '=ks-x1001)
1710 (setq code (encode-char char '=ucs@ks)))
1711 (format "u%04x-k" code)
1713 (format (format "%s%%0%d%s%s"
1717 (or (nth 4 spec) ""))
1724 (provide 'cwiki-common)
1726 ;;; cwiki-common.el ends here