1 ;; -*- coding: utf-8-mcs-er -*-
2 (require 'char-db-util)
3 ;; (require 'concord-images)
5 (setq file-name-coding-system 'utf-8-mcs-er)
8 (concord-assign-genre 'image-resource "/usr/local/var/photo/db")
9 (concord-assign-genre 'glyph-image "/usr/local/var/photo/db")
11 (concord-assign-genre 'creator@ruimoku "/usr/local/var/ruimoku/db")
12 (concord-assign-genre 'person-name@ruimoku "/usr/local/var/ruimoku/db")
14 (concord-assign-genre 'journal-volume@ruimoku "/usr/local/var/ruimoku/db")
15 (concord-assign-genre 'article@ruimoku "/usr/local/var/ruimoku/db")
16 (concord-assign-genre 'book@ruimoku "/usr/local/var/ruimoku/db")
18 (concord-assign-genre 'classification@ruimoku "/usr/local/var/ruimoku/db")
19 (concord-assign-genre 'region@ruimoku "/usr/local/var/ruimoku/db")
20 (concord-assign-genre 'era@ruimoku "/usr/local/var/ruimoku/db")
21 (concord-assign-genre 'period@ruimoku "/usr/local/var/ruimoku/db")
22 (concord-assign-genre 'journal@ruimoku "/usr/local/var/ruimoku/db")
23 (concord-assign-genre 'journal-name@ruimoku "/usr/local/var/ruimoku/db")
24 (concord-assign-genre 'publisher@ruimoku "/usr/local/var/ruimoku/db")
25 (concord-assign-genre 'publisher-name@ruimoku "/usr/local/var/ruimoku/db")
27 (mount-char-attribute-table '*instance@ruimoku/bibliography/title)
28 ;; (mount-char-attribute-table '*instance@ruimoku/bibliography/content*note)
30 (concord-assign-genre 'entry@zh-classical "/usr/local/var/kanbun/db")
31 ;; (concord-assign-genre 'morpheme-entry@zh-classical "/usr/local/var/kanbun/db")
32 (concord-assign-genre 'word-class@zh-classical "/usr/local/var/kanbun/db")
33 (concord-assign-genre 'morpheme@zh-classical "/usr/local/var/kanbun/db")
34 (concord-assign-genre 'sentence@zh-classical "/usr/local/var/kanbun/db")
35 ;; (concord-assign-genre 'sentence-entry@zh-classical "/usr/local/var/kanbun/db")
37 (mount-char-attribute-table '*instance@morpheme-entry/zh-classical)
40 (concord-assign-genre 'hng-card "/usr/local/var/hng-card/db")
42 (mount-char-attribute-table '->HNG)
43 (mount-char-attribute-table '<-HNG)
46 (defvar est-hide-cgi-mode nil)
47 (defvar est-view-url-prefix "..")
48 (defvar chise-wiki-view-url "view.cgi")
49 (defvar chise-wiki-edit-url "edit.cgi")
51 (defvar chise-wiki-bitmap-glyphs-url
52 "http://www.chise.org/glyphs")
54 (defvar chise-wiki-hng-bitmap-glyphs-url
55 "http://hng.chise.org/glyphs/HNG")
57 (defvar chise-wiki-glyph-cgi-url
58 "http://www.chise.org/chisewiki/glyph.cgi")
60 (defvar chise-wiki-displayed-features nil)
62 (defvar est-coded-charset-priority-list
64 =cns11643-1 =cns11643-2 =cns11643-3
65 =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7
67 =jis-x0208 =jis-x0208@1990
72 =jis-x0213-1@2000 =jis-x0213-1@2004
73 =jis-x0208@1983 =jis-x0208@1978
74 =zinbun-oracle =>zinbun-oracle
78 =>>>jis-x0208 =>>>jis-x0213-1 =>>>jis-x0213-2
79 =>>jis-x0208 =>>jis-x0213-1 =>>jis-x0213-2
81 =+>jis-x0208 =+>jis-x0213-1 =+>jis-x0213-2
84 =>jis-x0208 =>jis-x0213-1
86 =>ucs@iso =>ucs@unicode
87 =>ucs@jis =>ucs@cns =>ucs@ks
88 =>>ucs@iso =>>ucs@unicode
89 =>>ucs@jis =>>ucs@cns =>>ucs@ks
90 =>>>ucs@iso =>>>ucs@unicode
91 =>>>ucs@jis =>>>ucs@cns =>>>ucs@ks
112 (defun decode-uri-string (string &optional coding-system)
113 (if (> (length string) 0)
117 (mapconcat (lambda (char)
120 (char-to-string char)))
122 (while (string-match "%\\([0-9A-F][0-9A-F]\\)" string i)
123 (setq dest (concat dest
124 (substring string i (match-beginning 0))
127 (string-to-int (match-string 1 string) 16))))
129 (decode-coding-string
130 (concat dest (substring string i))
133 (defun www-feature-type (feature-name)
134 (or (char-feature-property feature-name 'type)
135 (let ((str (symbol-name feature-name)))
137 ((string-match "\\*note\\(@[^*]+\\)?$" str)
139 ((string-match "\\*sources\\(@[^*]+\\)?$" str)
141 ((string-match "\\*" str)
143 ((string-match "^\\(->\\|<-\\)" str)
145 ((string-match "^ideographic-structure\\(@\\|$\\)" str)
149 (defun www-feature-format (feature-name)
150 (or (char-feature-property feature-name 'presentation-format)
151 (char-feature-property feature-name 'format)
153 (setq fn feature-name)
154 (while (and (setq parent (char-feature-name-parent fn))
156 (char-feature-property
160 '((name) " : " (value))))
162 (defun www-feature-value-format (feature-name)
163 (or (char-feature-property feature-name 'value-presentation-format)
164 (char-feature-property feature-name 'value-format)
166 (setq fn feature-name)
167 (while (and (setq parent (char-feature-name-parent fn))
169 (or (char-feature-property
170 parent 'value-presentation-format)
171 (char-feature-property
172 parent 'value-format)))))
175 (let ((type (www-feature-type feature-name)))
176 (cond ((eq type 'relation)
178 ((eq type 'structure)
179 'space-separated-ids)
183 (if (find-charset feature-name)
184 (if (and (= (charset-dimension feature-name) 2)
185 (= (charset-chars feature-name) 94))
187 " (" (decimal) ") <" (ku-ten) "> " (prev-char) (next-char))
188 '("0x" (HEX) " (" (decimal) ") " (prev-char) (next-char))))
191 (defun char-feature-name-at-domain (feature-name domain)
193 (let ((name (symbol-name feature-name)))
195 ((string-match "@[^*]+$" name)
196 (intern (format "%s/%s" name domain))
199 (intern (format "%s@%s" name domain))
203 (defun char-feature-name-parent (feature-name)
204 (let ((name (symbol-name feature-name)))
205 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
206 (intern (substring name 0 (car (last (match-data) 2)))))))
208 (defun char-feature-name-domain (feature-name)
209 (let ((name (symbol-name feature-name)))
210 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
211 (intern (substring name (1+ (match-beginning 0)))))))
213 (defun char-feature-name-sans-versions (feature)
214 (let ((feature-name (symbol-name feature)))
215 (if (string-match "[@/]\\$rev=latest$" feature-name)
216 (intern (substring feature-name 0 (match-beginning 0)))
219 (defun est-object-genre (object)
220 (if (characterp object)
222 (concord-object-genre object)))
224 (defun www-get-feature-value (object feature)
225 (let ((latest-feature (char-feature-name-at-domain feature '$rev=latest)))
228 (mount-char-attribute-table latest-feature)
229 (or (char-feature object latest-feature)
230 (char-feature object feature))
233 (or (condition-case nil
234 (concord-object-get object latest-feature)
237 (concord-object-get object feature)
241 (defun get-previous-code-point (ccs code)
242 (let ((chars (charset-chars ccs))
243 (dim (charset-dimension ccs))
245 mask byte-min byte-max
268 (setq bytes (make-vector dim 0))
270 (aset bytes i (logand (lsh code (* i -8)) mask))
273 (while (and (< i dim)
275 (aset bytes i (1- (aref bytes i)))
276 (< (aref bytes i) byte-min)))
277 (aset bytes i byte-max)
280 (setq dest (aref bytes 0)
283 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
287 (defun get-next-code-point (ccs code)
288 (let ((chars (charset-chars ccs))
289 (dim (charset-dimension ccs))
291 mask byte-min byte-max
314 (setq bytes (make-vector dim 0))
316 (aset bytes i (logand (lsh code (* i -8)) mask))
319 (while (and (< i dim)
321 (aset bytes i (1+ (aref bytes i)))
322 (> (aref bytes i) byte-max)))
323 (aset bytes i byte-min)
326 (setq dest (aref bytes 0)
329 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
333 (defun find-previous-defined-code-point (ccs code)
334 (let ((i (get-previous-code-point ccs code))
337 ((eq ccs '=jis-x0208)
338 (setq ccs '=jis-x0208@1990))
339 ((eq ccs '=jis-x0213-1)
340 (setq ccs '=jis-x0213-1@2004)))
343 (null (setq char (decode-char ccs i
344 (unless (eq ccs '=ucs)
346 (setq i (get-previous-code-point ccs i)))
349 (defun find-next-defined-code-point (ccs code)
350 (let ((i (get-next-code-point ccs code))
352 (setq max (+ code 1000))
354 ((eq ccs '=jis-x0208)
355 (setq ccs '=jis-x0208@1990))
356 ((eq ccs '=jis-x0213-1)
357 (setq ccs '=jis-x0213-1@2004)))
360 (null (setq char (decode-char ccs i
361 (unless (eq ccs '=ucs)
363 (setq i (get-next-code-point ccs i)))
367 ;;; @ URI representation
370 (defun est-uri-decode-feature-name-body (uri-feature)
371 (let ((len (length uri-feature))
378 (if (eq (aref uri-feature i) ?\.)
379 (if (and (< (+ i 2) len)
380 (eq (aref uri-feature (+ i 2)) ?\.))
383 ((eq (setq ch (aref uri-feature (1+ i))) ?\.)
388 (substring uri-feature i (+ i 3))
394 (char-to-string (aref uri-feature i))
398 (defun est-uri-encode-feature-name-body (feature)
399 (mapconcat (lambda (c)
404 (t (char-to-string c))))
407 (defun www-uri-decode-feature-name (uri-feature)
409 (setq uri-feature (decode-uri-string uri-feature 'utf-8-mcs-er))
411 ((string-match "^from\\." uri-feature)
412 (intern (format "<-%s"
413 (est-uri-decode-feature-name-body
414 (substring uri-feature (match-end 0)))))
416 ((string-match "^to\\." uri-feature)
417 (intern (format "->%s"
418 (est-uri-decode-feature-name-body
419 (substring uri-feature (match-end 0)))))
421 ((string-match "^rep\\." uri-feature)
422 (intern (format "=%s"
423 (est-uri-decode-feature-name-body
424 (substring uri-feature (match-end 0)))))
426 ((string-match "^rep[2i]\\." uri-feature)
427 (intern (format "===%s"
428 (est-uri-decode-feature-name-body
429 (substring uri-feature (match-end 0)))))
431 ((string-match "^g\\." uri-feature)
432 (intern (format "=>>%s"
433 (est-uri-decode-feature-name-body
434 (substring uri-feature (match-end 0)))))
436 ((string-match "^g[i2]\\." uri-feature)
437 (intern (format "==%s"
438 (est-uri-decode-feature-name-body
439 (substring uri-feature (match-end 0)))))
441 ((string-match "^gi\\([0-9]+\\)\\." uri-feature)
442 (intern (format "=>>%s%s"
443 (make-string (string-to-int
444 (match-string 1 uri-feature))
446 (est-uri-decode-feature-name-body
447 (substring uri-feature (match-end 0)))))
449 ((string-match "^o\\." uri-feature)
450 (intern (format "=+>%s"
451 (est-uri-decode-feature-name-body
452 (substring uri-feature (match-end 0)))))
454 ((string-match "^a\\." uri-feature)
455 (intern (format "=>%s"
456 (est-uri-decode-feature-name-body
457 (substring uri-feature (match-end 0)))))
459 ((string-match "^a\\([0-9]+\\)\\." uri-feature)
460 (intern (format "%s>%s"
461 (make-string (string-to-int
462 (match-string 1 uri-feature))
464 (est-uri-decode-feature-name-body
465 (substring uri-feature (match-end 0)))))
467 ((and (setq uri-feature (est-uri-decode-feature-name-body uri-feature))
468 (setq feature (intern (format "=>%s" uri-feature)))
469 (find-charset feature))
471 ((and (setq feature (intern (format "=>>%s" uri-feature)))
472 (find-charset feature))
474 ((and (setq feature (intern (format "=>>>%s" uri-feature)))
475 (find-charset feature))
477 ((and (setq feature (intern (format "=%s" uri-feature)))
478 (find-charset feature))
480 (t (intern uri-feature)))))
482 (defun www-uri-encode-feature-name (feature-name)
483 (setq feature-name (symbol-name feature-name))
485 ((string-match "^=\\+>\\([^=>]+\\)" feature-name)
487 (est-uri-encode-feature-name-body
488 (substring feature-name (match-beginning 1))))
490 ((string-match "^=\\([^=>]+\\)" feature-name)
492 (est-uri-encode-feature-name-body
493 (substring feature-name (match-beginning 1))))
495 ((string-match "^==\\([^=>]+\\)" feature-name)
497 (est-uri-encode-feature-name-body
498 (substring feature-name (match-beginning 1))))
500 ((string-match "^===\\([^=>]+\\)" feature-name)
502 (est-uri-encode-feature-name-body
503 (substring feature-name (match-beginning 1))))
505 ((string-match "^=>>\\([^=>]+\\)" feature-name)
507 (est-uri-encode-feature-name-body
508 (substring feature-name (match-beginning 1))))
510 ((string-match "^=>>>\\([^=>]+\\)" feature-name)
512 (est-uri-encode-feature-name-body
513 (substring feature-name (match-beginning 1))))
515 ((string-match "^=>>\\(>+\\)" feature-name)
517 (length (match-string 1 feature-name))
518 (est-uri-encode-feature-name-body
519 (substring feature-name (match-end 1))))
521 ((string-match "^=>\\([^=>]+\\)" feature-name)
523 (est-uri-encode-feature-name-body
524 (substring feature-name (match-beginning 1))))
526 ((string-match "^\\(=+\\)>" feature-name)
528 (length (match-string 1 feature-name))
529 (est-uri-encode-feature-name-body
530 (substring feature-name (match-end 0))))
532 ((string-match "^->" feature-name)
534 (est-uri-encode-feature-name-body
535 (substring feature-name (match-end 0))))
537 ((string-match "^<-" feature-name)
539 (est-uri-encode-feature-name-body
540 (substring feature-name (match-end 0))))
542 (t (est-uri-encode-feature-name-body feature-name))))
544 (defun www-uri-make-feature-name-url (uri-genre uri-feature-name uri-object)
545 (if est-hide-cgi-mode
546 (format "../feature/%s&%s/%s"
547 uri-feature-name uri-genre uri-object)
548 (format "%s?feature=%s&%s=%s"
549 chise-wiki-view-url uri-feature-name uri-genre uri-object)))
551 (defun www-uri-decode-object (genre char-rep)
554 ((string-match (if est-hide-cgi-mode
555 "\\(%3D\\|=\\|%3A\\|:\\)"
556 "\\(%3A\\|:\\)") char-rep)
557 (setq ccs (substring char-rep 0 (match-beginning 0))
558 cpos (substring char-rep (match-end 0)))
559 (setq ccs (www-uri-decode-feature-name ccs))
560 (setq cpos (est-uri-decode-feature-name-body cpos))
562 ((string-match "^0x" cpos)
564 (string-to-number (substring cpos (match-end 0)) 16))
567 (setq cpos (car (read-from-string
569 cpos file-name-coding-system))))
571 (if (and (eq genre 'character)
573 (decode-char ccs cpos)
574 (concord-decode-object ccs cpos genre))
577 (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er))
579 ((eq genre 'character)
580 (when (= (length char-rep) 1)
584 (concord-decode-object
585 '=id (www-uri-decode-feature-name char-rep) 'feature)
588 (concord-decode-object
589 '=id (car (read-from-string char-rep)) genre)
592 (defun www-uri-encode-object (object)
593 (if (characterp object)
594 (if (encode-char object '=ucs)
597 (format "%%%02X" byte))
598 (encode-coding-string (char-to-string object) 'utf-8-mcs-er)
600 (let ((ccs-list est-coded-charset-priority-list)
603 (setq ccs (pop ccs-list))
604 (not (setq ret (encode-char object ccs 'defined-only)))))
606 (format (if est-hide-cgi-mode
609 (www-uri-encode-feature-name ccs)
611 ((and (setq ccs (car (split-char object)))
612 (setq ret (encode-char object ccs)))
613 (format (if est-hide-cgi-mode
616 (www-uri-encode-feature-name ccs)
619 (format (if est-hide-cgi-mode
620 "system-char-id=0x%X"
621 "system-char-id:0x%X")
622 (encode-char object 'system-char-id))
624 (format (if est-hide-cgi-mode
627 (est-uri-encode-feature-name-body
628 (format "%s" (concord-object-id object))))))
630 (defun est-format-object (object &optional readable)
631 (if (characterp object)
632 (char-to-string object)
633 (let ((ret (or (if readable
634 (or (concord-object-get object 'name)
635 (concord-object-get object '=name)
636 (concord-object-get object 'title)))
637 (concord-object-id object))))
640 (defun www-uri-make-object-url (object &optional uri-object)
641 (if est-hide-cgi-mode
644 (est-object-genre object)
646 (www-uri-encode-object object)))
649 (est-object-genre object)
651 (www-uri-encode-object object)))))
654 ;;; @ Feature name presentation
657 (defun www-format-feature-name-default (feature-name)
661 (symbol-name feature-name)
665 (defun www-format-feature-name-as-metadata (feature-name &optional lang)
666 (let ((str (symbol-name feature-name))
669 ((string-match "\\*[^*]+$" str)
670 (setq base (substring str 0 (match-beginning 0))
671 meta (substring str (match-beginning 0)))
672 (concat (www-format-feature-name* (intern base) lang)
675 (www-format-feature-name-default feature-name)
678 (defun www-format-feature-name-as-rel-to (feature-name)
679 (concat "\u2192" (substring (symbol-name feature-name) 2)))
681 (defun www-format-feature-name-as-rel-from (feature-name)
682 (concat "\u2190" (substring (symbol-name feature-name) 2)))
684 (defun www-format-feature-name-as-CCS (feature-name)
687 (symbol-name feature-name)
689 (dest (upcase (pop rest))))
690 (when (string-match "^=+>*" dest)
691 (setq dest (concat (substring dest 0 (match-end 0))
693 (substring dest (match-end 0)))))
697 (setq dest (concat dest " " (upcase (pop rest)))))
698 (if (string-match "^[0-9]+$" (car rest))
699 (concat dest "-" (car rest))
700 (concat dest " " (upcase (car rest))))
704 (defun www-format-feature-name* (feature-name &optional lang)
705 (let (name fn parent ret)
708 (char-feature-property
710 (intern (format "name@%s" lang))))
711 (char-feature-property
712 feature-name 'name)))
713 ((and (setq name (symbol-name feature-name))
714 (string-match "\\*" name))
715 (www-format-feature-name-as-metadata feature-name lang))
717 (setq fn feature-name)
718 (while (and (setq parent (char-feature-name-parent fn))
721 (char-feature-property
723 (intern (format "name@%s" lang))))
724 (char-feature-property
729 (concat ret (substring (symbol-name feature-name)
730 (length (symbol-name parent)))))
731 ((find-charset feature-name)
732 (www-format-feature-name-as-CCS feature-name))
733 ((string-match "^\\(->\\)" name)
734 (www-format-feature-name-as-rel-to feature-name))
735 ((string-match "^\\(<-\\)" name)
736 (www-format-feature-name-as-rel-from feature-name))
738 (www-format-feature-name-default feature-name)
742 (defun www-format-feature-name (feature-name &optional lang)
743 (www-format-encode-string
744 (www-format-feature-name* feature-name lang)))
750 (defvar www-format-char-img-style "vertical-align:bottom;")
752 (defun www-format-encode-string (string &optional without-tags as-body)
755 (let (plane code subcode start end char variants ret rret)
757 (goto-char (point-min))
758 (while (search-forward "&" nil t)
759 (replace-match "&" nil t)))
760 (goto-char (point-min))
761 (while (search-forward "<" nil t)
762 (replace-match "<" nil t))
763 (goto-char (point-min))
764 (while (search-forward ">" nil t)
765 (replace-match ">" nil t))
767 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
768 (let ((coded-charset-entity-reference-alist
772 '(=hanyo-denshi/ja "HD-JA-" 4 X)
773 '(=hanyo-denshi/jb "HD-JB-" 4 X)
774 '(=hanyo-denshi/jc "HD-JC-" 4 X)
775 '(=hanyo-denshi/jd "HD-JD-" 4 X)
776 '(=hanyo-denshi/ft "HD-FT-" 4 X)
777 '(=hanyo-denshi/ia "HD-IA-" 4 X)
778 '(=hanyo-denshi/ib "HD-IB-" 4 X)
779 '(=hanyo-denshi/hg "HD-HG-" 4 X)
780 '(=hanyo-denshi/ip "HD-IP-" 4 X)
781 '(=hanyo-denshi/jt "HD-JT-" 4 X)
782 '(=hanyo-denshi/ks "HD-KS-" 6 d)
783 '(=>>hanyo-denshi/ja "G-HD-JA-" 4 X)
784 '(=>>hanyo-denshi/jb "G-HD-JB-" 4 X)
785 '(=>>hanyo-denshi/jc "G-HD-JC-" 4 X)
786 '(=>>hanyo-denshi/jd "G-HD-JD-" 4 X)
787 '(=>>hanyo-denshi/ft "G-HD-FT-" 4 X)
788 '(=>>hanyo-denshi/ia "G-HD-IA-" 4 X)
789 '(=>>hanyo-denshi/ib "G-HD-IB-" 4 X)
790 '(=>>hanyo-denshi/hg "G-HD-HG-" 4 X)
791 '(=>>hanyo-denshi/ip "G-HD-IP-" 4 X)
792 '(=>>hanyo-denshi/jt "G-HD-JT-" 4 X)
793 '(=>>hanyo-denshi/ks "G-HD-KS-" 6 d)
795 '(==hanyo-denshi/ja "g2-HD-JA-" 4 X)
796 '(==hanyo-denshi/jb "g2-HD-JB-" 4 X)
797 '(==hanyo-denshi/jc "g2-HD-JC-" 4 X)
798 '(==hanyo-denshi/jd "g2-HD-JD-" 4 X)
799 '(==hanyo-denshi/ft "g2-HD-FT-" 4 X)
800 '(==hanyo-denshi/ia "g2-HD-IA-" 4 X)
801 '(==hanyo-denshi/ib "g2-HD-IB-" 4 X)
802 '(==hanyo-denshi/hg "g2-HD-HG-" 4 X)
803 '(==hanyo-denshi/ip "g2-HD-IP-" 4 X)
804 '(==hanyo-denshi/jt "g2-HD-JT-" 4 X)
805 '(==hanyo-denshi/ks "g2-HD-KS-" 6 d)
806 '(=cns11643-1 "C1-" 4 X)
807 '(=cns11643-2 "C2-" 4 X)
808 '(=cns11643-3 "C3-" 4 X)
809 '(=cns11643-4 "C4-" 4 X)
810 '(=cns11643-5 "C5-" 4 X)
811 '(=cns11643-6 "C6-" 4 X)
812 '(=cns11643-7 "C7-" 4 X)
813 '(=adobe-japan1-6 "AJ1-" 5 d)
814 '(=big5-cdp "CDP-" 4 X)
816 '(=gb12345 "G1-" 4 X)
817 '(=jis-x0208@1990 "J90-" 4 X)
818 '(=jis-x0212 "JSP-" 4 X)
820 '(=jis-x0208@1997 "J97-" 4 X)
821 '(=jis-x0208@1978 "J78-" 4 X)
822 '(=jis-x0208@1983 "J83-" 4 X)
823 '(=ruimoku-v6 "RUI6-" 4 X)
824 '(=zinbun-oracle "ZOB-" 4 d)
825 '(=jef-china3 "JC3-" 4 X)
826 '(=ucs@unicode "UU+" 4 X)
827 '(=ucs@JP/hanazono "hanaJU+" 4 X)
828 '(==cns11643-1 "R-C1-" 4 X)
829 '(==cns11643-2 "R-C2-" 4 X)
830 '(==cns11643-3 "R-C3-" 4 X)
831 '(==cns11643-4 "R-C4-" 4 X)
832 '(==cns11643-5 "R-C5-" 4 X)
833 '(==cns11643-6 "R-C6-" 4 X)
834 '(==cns11643-7 "R-C7-" 4 X)
835 '(=hanziku-1 "HZK01-" 4 X)
836 '(=hanziku-2 "HZK02-" 4 X)
837 '(=hanziku-3 "HZK03-" 4 X)
838 '(=hanziku-4 "HZK04-" 4 X)
839 '(=hanziku-5 "HZK05-" 4 X)
840 '(=hanziku-6 "HZK06-" 4 X)
841 '(=hanziku-7 "HZK07-" 4 X)
842 '(=hanziku-8 "HZK08-" 4 X)
843 '(=hanziku-9 "HZK09-" 4 X)
844 '(=hanziku-10 "HZK10-" 4 X)
845 '(=hanziku-11 "HZK11-" 4 X)
846 '(=hanziku-12 "HZK12-" 4 X)
848 '(=daikanwa "M-" 5 d)
849 coded-charset-entity-reference-alist)))
850 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
852 (goto-char (point-min))
853 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\)?CB\\([0-9]+\\);" nil t)
854 (setq code (string-to-int (match-string 2)))
856 (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
859 chise-wiki-bitmap-glyphs-url
861 www-format-char-img-style)
864 (goto-char (point-min))
865 (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)
866 (setq plane (match-string 2)
867 code (string-to-int (match-string 3) 16))
869 (format "<img alt=\"J%s-%04X\" src=\"%s/JIS-%s/%02d-%02d.gif\"
872 chise-wiki-bitmap-glyphs-url
875 (- (logand code 255) 32)
876 www-format-char-img-style)
879 (goto-char (point-min))
880 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?J0-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
881 (setq code (string-to-int (match-string 2) 16))
883 (format "<img alt=\"J0-%04X\" src=\"%s/JIS-90/%02d-%02d.gif\"
886 chise-wiki-bitmap-glyphs-url
888 (- (logand code 255) 32)
889 www-format-char-img-style)
892 (goto-char (point-min))
893 (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)
894 (setq plane (match-string 2)
895 code (string-to-int (match-string 3) 16))
897 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%02d%02d.png\"
900 chise-wiki-bitmap-glyphs-url
903 (- (logand code 255) 32)
904 www-format-char-img-style)
907 (goto-char (point-min))
908 (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)
909 (setq plane (match-string 2)
910 code (string-to-int (match-string 3) 16))
912 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%04X.png\"
915 chise-wiki-bitmap-glyphs-url
917 www-format-char-img-style)
920 (goto-char (point-min))
921 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-KS-\\([0-9]+\\);" nil t)
922 (setq code (string-to-int (match-string 2)))
924 (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/KS%06d.png\"
925 style=\"vertical-align:middle\">"
927 chise-wiki-bitmap-glyphs-url
929 www-format-char-img-style)
932 (goto-char (point-min))
933 (while (re-search-forward "&G\\([01]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
934 (setq plane (string-to-int (match-string 1))
935 code (string-to-int (match-string 2) 16))
937 (format "<img alt=\"GB%d-%04X\" src=\"%s/GB%d/%02d-%02d.gif\"
940 chise-wiki-bitmap-glyphs-url
943 (- (logand code 255) 32)
944 www-format-char-img-style)
947 (goto-char (point-min))
948 (while (re-search-forward "&\\(R-\\)?C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
949 (setq plane (string-to-int (match-string 2))
950 code (string-to-int (match-string 3) 16))
952 (format "<img alt=\"CNS%d-%04X\" src=\"%s/CNS%d/%04X.gif\"
955 chise-wiki-bitmap-glyphs-url
957 www-format-char-img-style)
960 (goto-char (point-min))
961 (while (re-search-forward "&\\(R-\\)?JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
962 (setq code (string-to-int (match-string 2) 16))
964 (format "<img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">"
968 (goto-char (point-min))
969 (while (re-search-forward "&\\(A-\\)?ZOB-\\([0-9]+\\);" nil t)
970 (setq code (string-to-int (match-string 2)))
972 (format "<img alt=\"ZOB-%04d\" src=\"%s/ZOB-1968/%04d.png\"
973 style=\"vertical-align:middle\">"
975 chise-wiki-bitmap-glyphs-url
977 www-format-char-img-style)
980 (goto-char (point-min))
981 (while (re-search-forward "&HNG\\([0-9]+\\)-\\([0-9][0-9][0-9][0-9]\\)\\([0-9]\\);" nil t)
982 (setq plane (match-string 1)
983 code (string-to-int (match-string 2))
984 subcode (string-to-int (match-string 3)))
988 (char-to-string (decode-char 'ascii (+ 96 subcode)))))
991 "<div class=\"tooltip\"><img alt=\"HNG%s-%04d%s\" src=\"%s/%s/%04d%s.png\" style=\"
992 vertical-align:middle; width: 48px; height: 48px\"><span
993 class=\"tooltiptext\">%s</span></div>"
995 chise-wiki-hng-bitmap-glyphs-url
998 (car (find (format "HNG%s-" plane)
999 coded-charset-entity-reference-alist
1000 :test (lambda (key cell)
1001 (string= key (nth 1 cell))))))
1005 (goto-char (point-min))
1006 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?AJ1-\\([0-9]+\\);" nil t)
1007 (setq code (string-to-int (match-string 2)))
1009 (format "<img alt=\"AJ1-%05d\" src=\"%s/IVD/AdobeJapan1/CID+%d.png\"
1010 style=\"vertical-align:middle\">"
1012 chise-wiki-bitmap-glyphs-url
1014 www-format-char-img-style)
1017 (goto-char (point-min))
1018 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?MJ\\([0-9]+\\);" nil t)
1019 (setq code (string-to-int (match-string 2)))
1021 (format "<img alt=\"MJ%06d\" src=\"http://mojikiban.ipa.go.jp/search/MJ%06d\"
1022 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1025 www-format-char-img-style)
1028 (goto-char (point-min))
1029 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?IU[+-]\\([0-9A-F]+\\);" nil t)
1030 (setq code (string-to-int (match-string 2) 16))
1032 (format "<img alt=\"u%04x\" src=\"http://glyphwiki.org/glyph/u%04x.100px.png\"
1033 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1036 www-format-char-img-style)
1039 (goto-char (point-min))
1040 (while (re-search-forward "&A-compU[+-]\\([0-9A-F]+\\);" nil t)
1041 (setq code (string-to-int (match-string 1) 16))
1043 (format "<img alt=\"u%04x\" src=\"http://glyphwiki.org/glyph/u%04x.100px.png\"
1044 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1047 www-format-char-img-style)
1050 (goto-char (point-min))
1051 (while (re-search-forward "&U-i\\([0-9]+\\)\\+\\([0-9A-F]+\\);" nil t)
1052 (setq plane (string-to-int (match-string 1))
1053 code (string-to-int (match-string 2) 16))
1055 (format "<img alt=\"u%04x-itaiji-%03d\" src=\"http://glyphwiki.org/glyph/u%04x-itaiji-%03d.100px.png\"
1056 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1061 www-format-char-img-style)
1064 (goto-char (point-min))
1065 (while (re-search-forward "&A-IWDSU\\+\\([0-9A-F]+\\);" nil t)
1066 (setq code (string-to-int (match-string 1) 16))
1068 (format "<img alt=\"A-IWDSU+%04x\" src=\"http://glyphwiki.org/glyph/u%04x.100px.png\"
1069 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1072 www-format-char-img-style)
1075 (goto-char (point-min))
1076 (while (re-search-forward "&U-v\\([0-9]+\\)\\+\\([0-9A-F]+\\);" nil t)
1077 (setq plane (string-to-int (match-string 1))
1078 code (string-to-int (match-string 2) 16))
1080 (format "<img alt=\"u%04x-itaiji-%03d\" src=\"http://glyphwiki.org/glyph/u%04x-var-%03d.100px.png\"
1081 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1086 www-format-char-img-style)
1089 (goto-char (point-min))
1090 (while (re-search-forward "&\\(A-\\|G-\\|R-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
1091 (setq code (string-to-int (match-string 2)))
1093 (format "<img alt=\"GT-%05d\" src=\"%s?char=GT-%05d\"
1096 chise-wiki-glyph-cgi-url
1098 www-format-char-img-style)
1101 (goto-char (point-min))
1102 (while (re-search-forward "&\\(A-\\|G-\\)?GT-K\\([0-9]+\\);" nil t)
1103 (setq code (string-to-int (match-string 2)))
1105 (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\"
1108 chise-wiki-glyph-cgi-url
1110 www-format-char-img-style)
1113 (goto-char (point-min))
1114 (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
1115 (setq code (string-to-int (match-string 1) 16))
1117 (format "<img alt=\"B-%04X\" src=\"%s?char=B-%04X\"
1120 chise-wiki-glyph-cgi-url
1122 www-format-char-img-style)
1125 (goto-char (point-min))
1126 (while (re-search-forward "&\\(G-\\|g2-\\|R-\\)?CDP-\\([0-9A-F]+\\);" nil t)
1127 (setq code (string-to-int (match-string 2) 16))
1129 (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
1132 chise-wiki-glyph-cgi-url
1134 www-format-char-img-style)
1137 (goto-char (point-min))
1138 (while (re-search-forward
1139 "&\\(I-\\)?HZK\\(0[1-9]\\|1[0-2]\\)-\\([0-9A-F]+\\);" nil t)
1140 (setq plane (match-string 2)
1141 code (string-to-int (match-string 3) 16))
1143 (format "<img alt=\"HZK%s-%04X\" src=\"%s?char=HZK%s-%04X\"
1147 chise-wiki-glyph-cgi-url
1150 www-format-char-img-style)
1153 (goto-char (point-min))
1154 (while (re-search-forward "&\\(G-\\|g2-\\|R-\\)?RUI6-\\([0-9A-F]+\\);" nil t)
1155 (setq code (string-to-int (match-string 2) 16))
1157 (format "<img alt=\"RUI6-%04X\" src=\"%s?char=RUI6-%04X\"
1158 style=\"vertical-align:middle\">"
1160 chise-wiki-glyph-cgi-url
1162 www-format-char-img-style)
1165 (goto-char (point-min))
1166 (while (re-search-forward "&hanaJU\\+\\([0-9A-F]+\\);" nil t)
1167 (setq code (string-to-int (match-string 1) 16))
1169 (format "<img alt=\"hanaJU+%04X\" src=\"%s?char=hana-JU+%04X\"
1170 style=\"vertical-align:middle\">"
1172 chise-wiki-glyph-cgi-url
1174 www-format-char-img-style)
1177 (goto-char (point-min))
1178 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\|R-\\)?\\(UU\\+\\|U-\\)\\([0-9A-F]+\\);" nil t)
1179 (setq code (string-to-int (match-string 3) 16))
1181 (format "<img alt=\"UU+%04X\" src=\"http://www.unicode.org/cgi-bin/refglyph?24-%04X\"
1182 style=\"vertical-align:middle\">"
1185 www-format-char-img-style)
1188 (goto-char (point-min))
1189 (while (re-search-forward "&MCS-\\([0-9A-F]+\\);" nil t)
1190 (setq code (string-to-int (match-string 1) 16))
1191 (setq start (match-beginning 0)
1193 (setq char (decode-char 'system-char-id code))
1195 ((and (setq variants
1196 (or (www-get-feature-value char '->subsumptive)
1197 (www-get-feature-value char '->denotational)))
1199 (if (characterp variants)
1200 (setq variants (list variants)))
1201 (while (and variants
1202 (setq ret (www-format-encode-string
1203 (char-to-string (car variants))))
1204 (string-match "&MCS-\\([0-9A-F]+\\);" ret))
1205 (setq variants (cdr variants)))
1207 (unless (string-match "&MCS-\\([0-9A-F]+\\);" ret)
1209 (delete-region start end)
1212 ((setq ret (or (www-get-feature-value char 'ideographic-combination)
1213 (www-get-feature-value char 'ideographic-structure)))
1218 (if (characterp (setq rret (find-char ch)))
1221 (www-format-encode-string
1222 (char-to-string ch) without-tags)
1223 (www-format-encode-string
1224 (format "%S" ch) without-tags)))
1228 (delete-region start end)
1232 ;; (goto-char (point-min))
1233 ;; (while (search-forward ">-" nil t)
1234 ;; (replace-match "&GT-" t 'literal))
1237 (defun www-html-display-text (text)
1241 (goto-char (point-min))
1242 (while (search-forward "<" nil t)
1243 (replace-match "<" nil t))
1244 (goto-char (point-min))
1245 (while (search-forward ">" nil t)
1246 (replace-match ">" nil t))
1247 (goto-char (point-min))
1248 (while (re-search-forward "\\[\\[\\([^]|[]+\\)|\\([^][]+\\)\\]\\]" nil t)
1250 (format "<a href=\"%s\">%s</a>"
1254 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
1255 (goto-char (point-min))
1256 (while (search-forward ">-" nil t)
1257 (replace-match "&GT-" nil t))
1260 (defun www-html-display-paragraph (text)
1262 (www-html-display-text text)
1269 (defvar coded-charset-GlyphWiki-id-alist
1270 '((===adobe-japan1-0 "aj1-" 5 d nil)
1271 (===adobe-japan1-1 "aj1-" 5 d nil)
1272 (===adobe-japan1-2 "aj1-" 5 d nil)
1273 (===adobe-japan1-3 "aj1-" 5 d nil)
1274 (===adobe-japan1-4 "aj1-" 5 d nil)
1275 (===adobe-japan1-5 "aj1-" 5 d nil)
1276 (===adobe-japan1-6 "aj1-" 5 d nil)
1277 (===ucs@jis "u" 4 x nil)
1278 (===daikanwa "dkw-" 5 d nil)
1279 (===ucs@ks "u" 4 x "-k")
1280 (=ucs-var-001 "u" 4 x "-var-001")
1281 (=ucs-var-002 "u" 4 x "-var-002")
1282 (=ucs-var-003 "u" 4 x "-var-003")
1283 (=ucs-itaiji-001 "u" 4 x "-itaiji-001")
1284 (=ucs-itaiji-002 "u" 4 x "-itaiji-002")
1285 (=ucs-itaiji-003 "u" 4 x "-itaiji-003")
1286 (=ucs-itaiji-084 "u" 4 x "-itaiji-084")
1287 (==adobe-japan1-0 "aj1-" 5 d nil)
1288 (==adobe-japan1-1 "aj1-" 5 d nil)
1289 (==adobe-japan1-2 "aj1-" 5 d nil)
1290 (==adobe-japan1-3 "aj1-" 5 d nil)
1291 (==adobe-japan1-4 "aj1-" 5 d nil)
1292 (==adobe-japan1-5 "aj1-" 5 d nil)
1293 (==adobe-japan1-6 "aj1-" 5 d nil)
1294 (==ucs@jis "u" 4 x nil)
1295 (==ucs@iso "u" 4 x nil)
1296 (==ucs@cns "u" 4 x "-t")
1297 (==ucs@unicode "u" 4 x "-us")
1298 (==daikanwa "dkw-" 5 d nil)
1299 (==ucs@ks "u" 4 x "-k")
1300 (==jis-x0208@1978 "j78-" 4 x nil)
1301 (==jis-x0208 "j90-" 4 x nil)
1302 (==jis-x0208@1990 "j90-" 4 x nil)
1303 (==jis-x0208@1983 "j83-" 4 x nil)
1304 (==cbeta "cbeta-" 5 d nil)
1305 (=>>hanyo-denshi/ks "koseki-" 6 d nil)
1306 (=>>jis-x0208@1978 "j78-" 4 x nil)
1307 (=>>big5-cdp "cdp-" 4 x nil)
1308 (=>>jis-x0208 "j90-" 4 x nil)
1309 (=>>jis-x0208@1990 "j90-" 4 x nil)
1310 (=>>jis-x0208@1983 "j83-" 4 x nil)
1311 (=>>daikanwa "dkw-" 5 d nil)
1312 (=adobe-japan1-0 "aj1-" 5 d nil)
1313 (=adobe-japan1-1 "aj1-" 5 d nil)
1314 (=adobe-japan1-2 "aj1-" 5 d nil)
1315 (=adobe-japan1-3 "aj1-" 5 d nil)
1316 (=adobe-japan1-4 "aj1-" 5 d nil)
1317 (=adobe-japan1-5 "aj1-" 5 d nil)
1318 (=adobe-japan1-6 "aj1-" 5 d nil)
1319 (=decomposition@cid)
1320 (=decomposition@hanyo-denshi)
1321 (=hanyo-denshi/ks "koseki-" 6 d nil)
1322 (=koseki "koseki-" 6 d nil)
1323 (=ucs@jis "u" 4 x nil)
1324 (=ucs@cns "u" 4 x "-t")
1325 (=ucs@ks "u" 4 x "-k")
1326 (=ucs@JP "u" 4 x nil)
1327 (=ucs@gb "u" 4 x "-g")
1328 (=ucs@iso "u" 4 x "-u")
1329 (=ucs@unicode "u" 4 x "-us")
1330 (=big5-cdp "cdp-" 4 x nil)
1331 (=cbeta "cbeta-" 5 d nil)
1332 (=big5-cdp-var-3 "cdp-" 4 x "-var-3")
1333 (=big5-cdp-var-5 "cdp-" 4 x "-var-5")
1334 (=jef-china3 "jc3-" 4 x nil)
1335 (=jis-x0212 "jsp-" 4 x nil)
1336 (=jis-x0213-1@2000 "jx1-2000-" 4 x nil)
1337 (=jis-x0213-1@2004 "jx1-2004-" 4 x nil)
1338 (=jis-x0213-2 "jx2-" 4 x nil)
1339 (=gt-k "gt-k" 5 d nil)
1340 (=jis-x0208@1978/1pr "j78-" 4 x nil)
1341 (=jis-x0208@1978/-4pr "j78-" 4 x nil)
1342 (=jis-x0208@1978 "j78-" 4 x nil)
1343 (=+>jis-x0208@1978 "j78-" 4 x nil)
1344 (=+>jis-x0208 "j90-" 4 x nil)
1345 (=+>jis-x0208@1990 "j90-" 4 x nil)
1346 (=+>jis-x0208@1983 "j83-" 4 x nil)
1348 (=big5 "b-" 4 x nil)
1349 (=daikanwa "dkw-" 5 d nil)
1351 (=ks-x1001 "k0-" 4 x nil)
1352 (=cns11643-1 "c1-" 4 x nil)
1353 (=cns11643-2 "c2-" 4 x nil)
1354 (=cns11643-3 "c3-" 4 x nil)
1355 (=cns11643-4 "c4-" 4 x nil)
1356 (=cns11643-5 "c5-" 4 x nil)
1357 (=cns11643-6 "c6-" 4 x nil)
1358 (=cns11643-7 "c7-" 4 x nil)
1359 (=jis-x0208 "j90-" 4 x nil)
1360 (=jis-x0208@1990 "j90-" 4 x nil)
1361 (=jis-x0208@1983 "j83-" 4 x nil)
1364 (defun char-GlyphWiki-id (char)
1365 (let ((rest coded-charset-GlyphWiki-id-alist)
1368 (setq spec (pop rest))
1369 (null (setq ret (char-feature char (car spec))))))
1373 (mapconcat #'char-GlyphWiki-id ret "-"))
1374 (and (memq (car spec) '(=ucs@unicode '=ucs@iso))
1376 ((and (or (encode-char char '=jis-x0208@1990)
1377 (encode-char char '=jis-x0212)
1378 (encode-char char '=jis-x0213-1)
1379 (encode-char char '=jis-x0213-2))
1380 (setq code (encode-char char '=ucs@jis)))
1381 (format "u%04x" code)
1383 ((and (or (encode-char char '=gb2312)
1384 (encode-char char '=gb12345))
1385 (setq code (encode-char char '=ucs@gb)))
1386 (format "u%04x-g" code)
1388 ((and (or (encode-char char '=cns11643-1)
1389 (encode-char char '=cns11643-2)
1390 (encode-char char '=cns11643-3)
1391 (encode-char char '=cns11643-4)
1392 (encode-char char '=cns11643-5)
1393 (encode-char char '=cns11643-6)
1394 (encode-char char '=cns11643-7))
1395 (setq code (encode-char char '=ucs@cns)))
1396 (format "u%04x-t" code)
1398 ((and (encode-char char '=ks-x1001)
1399 (setq code (encode-char char '=ucs@ks)))
1400 (format "u%04x-k" code)
1402 (format (format "%s%%0%d%s%s"
1406 (or (nth 4 spec) ""))
1413 (provide 'cwiki-common)
1415 ;;; cwiki-common.el ends here