1 ;; -*- coding: utf-8-mcs-er -*-
2 (require 'char-db-util)
4 (setq file-name-coding-system 'utf-8-mcs-er)
7 (concord-assign-genre 'creator@ruimoku "/usr/local/var/ruimoku/db")
8 (concord-assign-genre 'person-name@ruimoku "/usr/local/var/ruimoku/db")
10 (concord-assign-genre 'journal-volume@ruimoku "/usr/local/var/ruimoku/db")
11 (concord-assign-genre 'article@ruimoku "/usr/local/var/ruimoku/db")
12 (concord-assign-genre 'book@ruimoku "/usr/local/var/ruimoku/db")
14 (concord-assign-genre 'classification@ruimoku "/usr/local/var/ruimoku/db")
15 (concord-assign-genre 'region@ruimoku "/usr/local/var/ruimoku/db")
16 (concord-assign-genre 'era@ruimoku "/usr/local/var/ruimoku/db")
17 (concord-assign-genre 'period@ruimoku "/usr/local/var/ruimoku/db")
18 (concord-assign-genre 'journal@ruimoku "/usr/local/var/ruimoku/db")
19 (concord-assign-genre 'journal-name@ruimoku "/usr/local/var/ruimoku/db")
20 (concord-assign-genre 'publisher@ruimoku "/usr/local/var/ruimoku/db")
21 (concord-assign-genre 'publisher-name@ruimoku "/usr/local/var/ruimoku/db")
23 (mount-char-attribute-table '*instance@ruimoku/bibliography/title)
24 ;; (mount-char-attribute-table '*instance@ruimoku/bibliography/content*note)
26 (concord-assign-genre 'entry@zh-classical "/usr/local/var/kanbun/db")
27 ;; (concord-assign-genre 'morpheme-entry@zh-classical "/usr/local/var/kanbun/db")
28 (concord-assign-genre 'word-class@zh-classical "/usr/local/var/kanbun/db")
29 (concord-assign-genre 'morpheme@zh-classical "/usr/local/var/kanbun/db")
30 (concord-assign-genre 'sentence@zh-classical "/usr/local/var/kanbun/db")
31 ;; (concord-assign-genre 'sentence-entry@zh-classical "/usr/local/var/kanbun/db")
33 (mount-char-attribute-table '*instance@morpheme-entry/zh-classical)
36 (mount-char-attribute-table '->HNG)
37 (mount-char-attribute-table '<-HNG)
40 (defvar est-hide-cgi-mode nil)
41 (defvar est-view-url-prefix "..")
42 (defvar chise-wiki-view-url "view.cgi")
43 (defvar chise-wiki-edit-url "edit.cgi")
45 (defvar chise-wiki-bitmap-glyphs-url
46 "http://www.chise.org/glyphs")
48 (defvar chise-wiki-hng-bitmap-glyphs-url
49 "http://hng.chise.org/glyphs/HNG")
51 (defvar chise-wiki-glyph-cgi-url
52 "http://www.chise.org/chisewiki/glyph.cgi")
54 (defvar chise-wiki-displayed-features nil)
56 (defvar est-coded-charset-priority-list
58 =cns11643-1 =cns11643-2 =cns11643-3
59 =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7
61 =jis-x0208 =jis-x0208@1990
66 =jis-x0213-1@2000 =jis-x0213-1@2004
67 =jis-x0208@1983 =jis-x0208@1978
68 =zinbun-oracle =>zinbun-oracle
72 =>>>jis-x0208 =>>>jis-x0213-1 =>>>jis-x0213-2
73 =>>jis-x0208 =>>jis-x0213-1 =>>jis-x0213-2
75 =+>jis-x0208 =+>jis-x0213-1 =+>jis-x0213-2
78 =>jis-x0208 =>jis-x0213-1
80 =>ucs@iso =>ucs@unicode
81 =>ucs@jis =>ucs@cns =>ucs@ks
82 =>>ucs@iso =>>ucs@unicode
83 =>>ucs@jis =>>ucs@cns =>>ucs@ks
84 =>>>ucs@iso =>>>ucs@unicode
85 =>>>ucs@jis =>>>ucs@cns =>>>ucs@ks
98 (defun decode-uri-string (string &optional coding-system)
99 (if (> (length string) 0)
103 (mapconcat (lambda (char)
106 (char-to-string char)))
108 (while (string-match "%\\([0-9A-F][0-9A-F]\\)" string i)
109 (setq dest (concat dest
110 (substring string i (match-beginning 0))
113 (string-to-int (match-string 1 string) 16))))
115 (decode-coding-string
116 (concat dest (substring string i))
119 (defun www-feature-type (feature-name)
120 (or (char-feature-property feature-name 'type)
121 (let ((str (symbol-name feature-name)))
123 ((string-match "\\*note\\(@[^*]+\\)?$" str)
125 ((string-match "\\*sources\\(@[^*]+\\)?$" str)
127 ((string-match "\\*" str)
129 ((string-match "^\\(->\\|<-\\)" str)
131 ((string-match "^ideographic-structure\\(@\\|$\\)" str)
135 (defun www-feature-format (feature-name)
136 (or (char-feature-property feature-name 'presentation-format)
137 (char-feature-property feature-name 'format)
139 (setq fn feature-name)
140 (while (and (setq parent (char-feature-name-parent fn))
142 (char-feature-property
146 '((name) " : " (value))))
148 (defun www-feature-value-format (feature-name)
149 (or (char-feature-property feature-name 'value-presentation-format)
150 (char-feature-property feature-name 'value-format)
152 (setq fn feature-name)
153 (while (and (setq parent (char-feature-name-parent fn))
155 (or (char-feature-property
156 parent 'value-presentation-format)
157 (char-feature-property
158 parent 'value-format)))))
161 (let ((type (www-feature-type feature-name)))
162 (cond ((eq type 'relation)
164 ((eq type 'structure)
165 'space-separated-ids)
169 (if (find-charset feature-name)
170 (if (and (= (charset-dimension feature-name) 2)
171 (= (charset-chars feature-name) 94))
173 " (" (decimal) ") <" (ku-ten) "> " (prev-char) (next-char))
174 '("0x" (HEX) " (" (decimal) ") " (prev-char) (next-char))))
177 (defun char-feature-name-at-domain (feature-name domain)
179 (let ((name (symbol-name feature-name)))
181 ((string-match "@[^*]+$" name)
182 (intern (format "%s/%s" name domain))
185 (intern (format "%s@%s" name domain))
189 (defun char-feature-name-parent (feature-name)
190 (let ((name (symbol-name feature-name)))
191 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
192 (intern (substring name 0 (car (last (match-data) 2)))))))
194 (defun char-feature-name-domain (feature-name)
195 (let ((name (symbol-name feature-name)))
196 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
197 (intern (substring name (1+ (match-beginning 0)))))))
199 (defun char-feature-name-sans-versions (feature)
200 (let ((feature-name (symbol-name feature)))
201 (if (string-match "[@/]\\$rev=latest$" feature-name)
202 (intern (substring feature-name 0 (match-beginning 0)))
205 (defun est-object-genre (object)
206 (if (characterp object)
208 (concord-object-genre object)))
210 (defun www-get-feature-value (object feature)
211 (let ((latest-feature (char-feature-name-at-domain feature '$rev=latest)))
214 (mount-char-attribute-table latest-feature)
215 (or (char-feature object latest-feature)
216 (char-feature object feature))
219 (or (condition-case nil
220 (concord-object-get object latest-feature)
223 (concord-object-get object feature)
227 (defun get-previous-code-point (ccs code)
228 (let ((chars (charset-chars ccs))
229 (dim (charset-dimension ccs))
231 mask byte-min byte-max
254 (setq bytes (make-vector dim 0))
256 (aset bytes i (logand (lsh code (* i -8)) mask))
259 (while (and (< i dim)
261 (aset bytes i (1- (aref bytes i)))
262 (< (aref bytes i) byte-min)))
263 (aset bytes i byte-max)
266 (setq dest (aref bytes 0)
269 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
273 (defun get-next-code-point (ccs code)
274 (let ((chars (charset-chars ccs))
275 (dim (charset-dimension ccs))
277 mask byte-min byte-max
300 (setq bytes (make-vector dim 0))
302 (aset bytes i (logand (lsh code (* i -8)) mask))
305 (while (and (< i dim)
307 (aset bytes i (1+ (aref bytes i)))
308 (> (aref bytes i) byte-max)))
309 (aset bytes i byte-min)
312 (setq dest (aref bytes 0)
315 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
319 (defun find-previous-defined-code-point (ccs code)
320 (let ((i (get-previous-code-point ccs code))
323 ((eq ccs '=jis-x0208)
324 (setq ccs '=jis-x0208@1990))
325 ((eq ccs '=jis-x0213-1)
326 (setq ccs '=jis-x0213-1@2004)))
329 (null (setq char (decode-char ccs i
330 (unless (eq ccs '=ucs)
332 (setq i (get-previous-code-point ccs i)))
335 (defun find-next-defined-code-point (ccs code)
336 (let ((i (get-next-code-point ccs code))
338 (setq max (+ code 1000))
340 ((eq ccs '=jis-x0208)
341 (setq ccs '=jis-x0208@1990))
342 ((eq ccs '=jis-x0213-1)
343 (setq ccs '=jis-x0213-1@2004)))
346 (null (setq char (decode-char ccs i
347 (unless (eq ccs '=ucs)
349 (setq i (get-next-code-point ccs i)))
353 ;;; @ URI representation
356 (defun est-uri-decode-feature-name-body (uri-feature)
357 (let ((len (length uri-feature))
364 (if (eq (aref uri-feature i) ?\.)
365 (if (and (< (+ i 2) len)
366 (eq (aref uri-feature (+ i 2)) ?\.))
369 ((eq (setq ch (aref uri-feature (1+ i))) ?\.)
374 (substring uri-feature i (+ i 3))
380 (char-to-string (aref uri-feature i))
384 (defun est-uri-encode-feature-name-body (feature)
385 (mapconcat (lambda (c)
390 (t (char-to-string c))))
393 (defun www-uri-decode-feature-name (uri-feature)
395 (setq uri-feature (decode-uri-string uri-feature 'utf-8-mcs-er))
397 ((string-match "^from\\." uri-feature)
398 (intern (format "<-%s"
399 (est-uri-decode-feature-name-body
400 (substring uri-feature (match-end 0)))))
402 ((string-match "^to\\." uri-feature)
403 (intern (format "->%s"
404 (est-uri-decode-feature-name-body
405 (substring uri-feature (match-end 0)))))
407 ((string-match "^rep\\." uri-feature)
408 (intern (format "=%s"
409 (est-uri-decode-feature-name-body
410 (substring uri-feature (match-end 0)))))
412 ((string-match "^rep[2i]\\." uri-feature)
413 (intern (format "===%s"
414 (est-uri-decode-feature-name-body
415 (substring uri-feature (match-end 0)))))
417 ((string-match "^g\\." uri-feature)
418 (intern (format "=>>%s"
419 (est-uri-decode-feature-name-body
420 (substring uri-feature (match-end 0)))))
422 ((string-match "^g[i2]\\." uri-feature)
423 (intern (format "==%s"
424 (est-uri-decode-feature-name-body
425 (substring uri-feature (match-end 0)))))
427 ((string-match "^gi\\([0-9]+\\)\\." uri-feature)
428 (intern (format "=>>%s%s"
429 (make-string (string-to-int
430 (match-string 1 uri-feature))
432 (est-uri-decode-feature-name-body
433 (substring uri-feature (match-end 0)))))
435 ((string-match "^o\\." uri-feature)
436 (intern (format "=+>%s"
437 (est-uri-decode-feature-name-body
438 (substring uri-feature (match-end 0)))))
440 ((string-match "^a\\." uri-feature)
441 (intern (format "=>%s"
442 (est-uri-decode-feature-name-body
443 (substring uri-feature (match-end 0)))))
445 ((string-match "^a\\([0-9]+\\)\\." uri-feature)
446 (intern (format "%s>%s"
447 (make-string (string-to-int
448 (match-string 1 uri-feature))
450 (est-uri-decode-feature-name-body
451 (substring uri-feature (match-end 0)))))
453 ((and (setq uri-feature (est-uri-decode-feature-name-body uri-feature))
454 (setq feature (intern (format "=>%s" uri-feature)))
455 (find-charset feature))
457 ((and (setq feature (intern (format "=>>%s" uri-feature)))
458 (find-charset feature))
460 ((and (setq feature (intern (format "=>>>%s" uri-feature)))
461 (find-charset feature))
463 ((and (setq feature (intern (format "=%s" uri-feature)))
464 (find-charset feature))
466 (t (intern uri-feature)))))
468 (defun www-uri-encode-feature-name (feature-name)
469 (setq feature-name (symbol-name feature-name))
471 ((string-match "^=\\+>\\([^=>]+\\)" feature-name)
473 (est-uri-encode-feature-name-body
474 (substring feature-name (match-beginning 1))))
476 ((string-match "^=\\([^=>]+\\)" feature-name)
478 (est-uri-encode-feature-name-body
479 (substring feature-name (match-beginning 1))))
481 ((string-match "^==\\([^=>]+\\)" feature-name)
483 (est-uri-encode-feature-name-body
484 (substring feature-name (match-beginning 1))))
486 ((string-match "^===\\([^=>]+\\)" feature-name)
488 (est-uri-encode-feature-name-body
489 (substring feature-name (match-beginning 1))))
491 ((string-match "^=>>\\([^=>]+\\)" feature-name)
493 (est-uri-encode-feature-name-body
494 (substring feature-name (match-beginning 1))))
496 ((string-match "^=>>>\\([^=>]+\\)" feature-name)
498 (est-uri-encode-feature-name-body
499 (substring feature-name (match-beginning 1))))
501 ((string-match "^=>>\\(>+\\)" feature-name)
503 (length (match-string 1 feature-name))
504 (est-uri-encode-feature-name-body
505 (substring feature-name (match-end 1))))
507 ((string-match "^=>\\([^=>]+\\)" feature-name)
509 (est-uri-encode-feature-name-body
510 (substring feature-name (match-beginning 1))))
512 ((string-match "^\\(=+\\)>" feature-name)
514 (length (match-string 1 feature-name))
515 (est-uri-encode-feature-name-body
516 (substring feature-name (match-end 0))))
518 ((string-match "^->" feature-name)
520 (est-uri-encode-feature-name-body
521 (substring feature-name (match-end 0))))
523 ((string-match "^<-" feature-name)
525 (est-uri-encode-feature-name-body
526 (substring feature-name (match-end 0))))
528 (t (est-uri-encode-feature-name-body feature-name))))
530 (defun www-uri-make-feature-name-url (uri-genre uri-feature-name uri-object)
531 (if est-hide-cgi-mode
532 (format "../feature/%s&%s/%s"
533 uri-feature-name uri-genre uri-object)
534 (format "%s?feature=%s&%s=%s"
535 chise-wiki-view-url uri-feature-name uri-genre uri-object)))
537 (defun www-uri-decode-object (genre char-rep)
540 ((string-match (if est-hide-cgi-mode
541 "\\(%3D\\|=\\|%3A\\|:\\)"
542 "\\(%3A\\|:\\)") char-rep)
543 (setq ccs (substring char-rep 0 (match-beginning 0))
544 cpos (substring char-rep (match-end 0)))
545 (setq ccs (www-uri-decode-feature-name ccs))
546 (setq cpos (est-uri-decode-feature-name-body cpos))
548 ((string-match "^0x" cpos)
550 (string-to-number (substring cpos (match-end 0)) 16))
553 (setq cpos (car (read-from-string
555 cpos file-name-coding-system))))
557 (if (and (eq genre 'character)
559 (decode-char ccs cpos)
560 (concord-decode-object ccs cpos genre))
563 (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er))
565 ((eq genre 'character)
566 (when (= (length char-rep) 1)
570 (concord-decode-object
571 '=id (www-uri-decode-feature-name char-rep) 'feature)
574 (concord-decode-object
575 '=id (car (read-from-string char-rep)) genre)
578 (defun www-uri-encode-object (object)
579 (if (characterp object)
580 (if (encode-char object '=ucs)
583 (format "%%%02X" byte))
584 (encode-coding-string (char-to-string object) 'utf-8-mcs-er)
586 (let ((ccs-list est-coded-charset-priority-list)
589 (setq ccs (pop ccs-list))
590 (not (setq ret (encode-char object ccs 'defined-only)))))
592 (format (if est-hide-cgi-mode
595 (www-uri-encode-feature-name ccs)
597 ((and (setq ccs (car (split-char object)))
598 (setq ret (encode-char object ccs)))
599 (format (if est-hide-cgi-mode
602 (www-uri-encode-feature-name ccs)
605 (format (if est-hide-cgi-mode
606 "system-char-id=0x%X"
607 "system-char-id:0x%X")
608 (encode-char object 'system-char-id))
610 (format (if est-hide-cgi-mode
613 (est-uri-encode-feature-name-body
614 (format "%s" (concord-object-id object))))))
616 (defun est-format-object (object &optional readable)
617 (if (characterp object)
618 (char-to-string object)
619 (let ((ret (or (if readable
620 (or (concord-object-get object 'name)
621 (concord-object-get object '=name)
622 (concord-object-get object 'title)))
623 (concord-object-id object))))
626 (defun www-uri-make-object-url (object &optional uri-object)
627 (if est-hide-cgi-mode
630 (est-object-genre object)
632 (www-uri-encode-object object)))
635 (est-object-genre object)
637 (www-uri-encode-object object)))))
640 ;;; @ Feature name presentation
643 (defun www-format-feature-name-default (feature-name)
647 (symbol-name feature-name)
651 (defun www-format-feature-name-as-metadata (feature-name &optional lang)
652 (let ((str (symbol-name feature-name))
655 ((string-match "\\*[^*]+$" str)
656 (setq base (substring str 0 (match-beginning 0))
657 meta (substring str (match-beginning 0)))
658 (concat (www-format-feature-name* (intern base) lang)
661 (www-format-feature-name-default feature-name)
664 (defun www-format-feature-name-as-rel-to (feature-name)
665 (concat "\u2192" (substring (symbol-name feature-name) 2)))
667 (defun www-format-feature-name-as-rel-from (feature-name)
668 (concat "\u2190" (substring (symbol-name feature-name) 2)))
670 (defun www-format-feature-name-as-CCS (feature-name)
673 (symbol-name feature-name)
675 (dest (upcase (pop rest))))
676 (when (string-match "^=+>*" dest)
677 (setq dest (concat (substring dest 0 (match-end 0))
679 (substring dest (match-end 0)))))
683 (setq dest (concat dest " " (upcase (pop rest)))))
684 (if (string-match "^[0-9]+$" (car rest))
685 (concat dest "-" (car rest))
686 (concat dest " " (upcase (car rest))))
690 (defun www-format-feature-name* (feature-name &optional lang)
691 (let (name fn parent ret)
694 (char-feature-property
696 (intern (format "name@%s" lang))))
697 (char-feature-property
698 feature-name 'name)))
699 ((and (setq name (symbol-name feature-name))
700 (string-match "\\*" name))
701 (www-format-feature-name-as-metadata feature-name lang))
703 (setq fn feature-name)
704 (while (and (setq parent (char-feature-name-parent fn))
707 (char-feature-property
709 (intern (format "name@%s" lang))))
710 (char-feature-property
715 (concat ret (substring (symbol-name feature-name)
716 (length (symbol-name parent)))))
717 ((find-charset feature-name)
718 (www-format-feature-name-as-CCS feature-name))
719 ((string-match "^\\(->\\)" name)
720 (www-format-feature-name-as-rel-to feature-name))
721 ((string-match "^\\(<-\\)" name)
722 (www-format-feature-name-as-rel-from feature-name))
724 (www-format-feature-name-default feature-name)
728 (defun www-format-feature-name (feature-name &optional lang)
729 (www-format-encode-string
730 (www-format-feature-name* feature-name lang)))
736 (defvar www-format-char-img-style "vertical-align:bottom;")
738 (defun www-format-encode-string (string &optional without-tags as-body)
741 (let (plane code subcode start end char variants ret rret)
743 (goto-char (point-min))
744 (while (search-forward "&" nil t)
745 (replace-match "&" nil t)))
746 (goto-char (point-min))
747 (while (search-forward "<" nil t)
748 (replace-match "<" nil t))
749 (goto-char (point-min))
750 (while (search-forward ">" nil t)
751 (replace-match ">" nil t))
753 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
754 (let ((coded-charset-entity-reference-alist
757 '(=hanyo-denshi/ja "HD-JA-" 4 X)
758 '(=hanyo-denshi/jb "HD-JB-" 4 X)
759 '(=hanyo-denshi/jc "HD-JC-" 4 X)
760 '(=hanyo-denshi/jd "HD-JD-" 4 X)
761 '(=hanyo-denshi/ft "HD-FT-" 4 X)
762 '(=hanyo-denshi/ia "HD-IA-" 4 X)
763 '(=hanyo-denshi/ib "HD-IB-" 4 X)
764 '(=hanyo-denshi/hg "HD-HG-" 4 X)
765 '(=hanyo-denshi/ip "HD-IP-" 4 X)
766 '(=hanyo-denshi/jt "HD-JT-" 4 X)
767 '(=hanyo-denshi/ks "HD-KS-" 6 d)
768 '(=>>hanyo-denshi/ja "G-HD-JA-" 4 X)
769 '(=>>hanyo-denshi/jb "G-HD-JB-" 4 X)
770 '(=>>hanyo-denshi/jc "G-HD-JC-" 4 X)
771 '(=>>hanyo-denshi/jd "G-HD-JD-" 4 X)
772 '(=>>hanyo-denshi/ft "G-HD-FT-" 4 X)
773 '(=>>hanyo-denshi/ia "G-HD-IA-" 4 X)
774 '(=>>hanyo-denshi/ib "G-HD-IB-" 4 X)
775 '(=>>hanyo-denshi/hg "G-HD-HG-" 4 X)
776 '(=>>hanyo-denshi/ip "G-HD-IP-" 4 X)
777 '(=>>hanyo-denshi/jt "G-HD-JT-" 4 X)
778 '(=>>hanyo-denshi/ks "G-HD-KS-" 6 d)
779 '(==hanyo-denshi/ja "g2-HD-JA-" 4 X)
780 '(==hanyo-denshi/jb "g2-HD-JB-" 4 X)
781 '(==hanyo-denshi/jc "g2-HD-JC-" 4 X)
782 '(==hanyo-denshi/jd "g2-HD-JD-" 4 X)
783 '(==hanyo-denshi/ft "g2-HD-FT-" 4 X)
784 '(==hanyo-denshi/ia "g2-HD-IA-" 4 X)
785 '(==hanyo-denshi/ib "g2-HD-IB-" 4 X)
786 '(==hanyo-denshi/hg "g2-HD-HG-" 4 X)
787 '(==hanyo-denshi/ip "g2-HD-IP-" 4 X)
788 '(==hanyo-denshi/jt "g2-HD-JT-" 4 X)
789 '(==hanyo-denshi/ks "g2-HD-KS-" 6 d)
790 '(=cns11643-1 "C1-" 4 X)
791 '(=cns11643-2 "C2-" 4 X)
792 '(=cns11643-3 "C3-" 4 X)
793 '(=cns11643-4 "C4-" 4 X)
794 '(=cns11643-5 "C5-" 4 X)
795 '(=cns11643-6 "C6-" 4 X)
796 '(=cns11643-7 "C7-" 4 X)
797 '(=adobe-japan1-6 "AJ1-" 5 d)
798 '(=big5-cdp "CDP-" 4 X)
800 '(=gb12345 "G1-" 4 X)
801 '(=jis-x0208@1990 "J90-" 4 X)
802 '(=jis-x0212 "JSP-" 4 X)
804 '(=jis-x0208@1997 "J97-" 4 X)
805 '(=jis-x0208@1978 "J78-" 4 X)
806 '(=jis-x0208@1983 "J83-" 4 X)
807 '(=ruimoku-v6 "RUI6-" 4 X)
808 '(=zinbun-oracle "ZOB-" 4 d)
809 '(=jef-china3 "JC3-" 4 X)
810 '(=ucs@unicode "UU+" 4 X)
811 '(=ucs@JP/hanazono "hanaJU+" 4 X)
812 '(=daikanwa "M-" 5 d)
813 '(==cns11643-1 "R-C1-" 4 X)
814 '(==cns11643-2 "R-C2-" 4 X)
815 '(==cns11643-3 "R-C3-" 4 X)
816 '(==cns11643-4 "R-C4-" 4 X)
817 '(==cns11643-5 "R-C5-" 4 X)
818 '(==cns11643-6 "R-C6-" 4 X)
819 '(==cns11643-7 "R-C7-" 4 X)
820 coded-charset-entity-reference-alist)))
821 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
823 (goto-char (point-min))
824 (while (re-search-forward "&\\(A-\\)?CB\\([0-9]+\\);" nil t)
825 (setq code (string-to-int (match-string 2)))
827 (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
830 chise-wiki-bitmap-glyphs-url
832 www-format-char-img-style)
835 (goto-char (point-min))
836 (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)
837 (setq plane (match-string 2)
838 code (string-to-int (match-string 3) 16))
840 (format "<img alt=\"J%s-%04X\" src=\"%s/JIS-%s/%02d-%02d.gif\"
843 chise-wiki-bitmap-glyphs-url
846 (- (logand code 255) 32)
847 www-format-char-img-style)
850 (goto-char (point-min))
851 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?J0-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
852 (setq code (string-to-int (match-string 2) 16))
854 (format "<img alt=\"J0-%04X\" src=\"%s/JIS-90/%02d-%02d.gif\"
857 chise-wiki-bitmap-glyphs-url
859 (- (logand code 255) 32)
860 www-format-char-img-style)
863 (goto-char (point-min))
864 (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)
865 (setq plane (match-string 2)
866 code (string-to-int (match-string 3) 16))
868 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%02d%02d.png\"
871 chise-wiki-bitmap-glyphs-url
874 (- (logand code 255) 32)
875 www-format-char-img-style)
878 (goto-char (point-min))
879 (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)
880 (setq plane (match-string 2)
881 code (string-to-int (match-string 3) 16))
883 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%04X.png\"
886 chise-wiki-bitmap-glyphs-url
888 www-format-char-img-style)
891 (goto-char (point-min))
892 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-KS-\\([0-9]+\\);" nil t)
893 (setq code (string-to-int (match-string 2)))
895 (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/KS%06d.png\"
896 style=\"vertical-align:middle\">"
898 chise-wiki-bitmap-glyphs-url
900 www-format-char-img-style)
903 (goto-char (point-min))
904 (while (re-search-forward "&G\\([01]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
905 (setq plane (string-to-int (match-string 1))
906 code (string-to-int (match-string 2) 16))
908 (format "<img alt=\"GB%d-%04X\" src=\"%s/GB%d/%02d-%02d.gif\"
911 chise-wiki-bitmap-glyphs-url
914 (- (logand code 255) 32)
915 www-format-char-img-style)
918 (goto-char (point-min))
919 (while (re-search-forward "&\\(R-\\)?C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
920 (setq plane (string-to-int (match-string 2))
921 code (string-to-int (match-string 3) 16))
923 (format "<img alt=\"CNS%d-%04X\" src=\"%s/CNS%d/%04X.gif\"
926 chise-wiki-bitmap-glyphs-url
928 www-format-char-img-style)
931 (goto-char (point-min))
932 (while (re-search-forward "&\\(R-\\)?JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
933 (setq code (string-to-int (match-string 2) 16))
935 (format "<img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">"
939 (goto-char (point-min))
940 (while (re-search-forward "&\\(A-\\)?ZOB-\\([0-9]+\\);" nil t)
941 (setq code (string-to-int (match-string 2)))
943 (format "<img alt=\"ZOB-%04d\" src=\"%s/ZOB-1968/%04d.png\"
944 style=\"vertical-align:middle\">"
946 chise-wiki-bitmap-glyphs-url
948 www-format-char-img-style)
951 (goto-char (point-min))
952 (while (re-search-forward "&HNG\\([0-9]+\\)-\\([0-9][0-9][0-9][0-9]\\)\\([0-9]\\);" nil t)
953 (setq plane (match-string 1)
954 code (string-to-int (match-string 2))
955 subcode (string-to-int (match-string 3)))
959 (char-to-string (decode-char 'ascii (+ 96 subcode)))))
962 "<img alt=\"HNG%s-%04d%s\" src=\"%s/%s/%04d%s.png\"
963 style=\"vertical-align:middle; width: 48px; height: 48px\">"
965 chise-wiki-hng-bitmap-glyphs-url
967 www-format-char-img-style)
970 (goto-char (point-min))
971 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?AJ1-\\([0-9]+\\);" nil t)
972 (setq code (string-to-int (match-string 2)))
974 (format "<img alt=\"AJ1-%05d\" src=\"%s/IVD/AdobeJapan1/CID+%d.png\"
975 style=\"vertical-align:middle\">"
977 chise-wiki-bitmap-glyphs-url
979 www-format-char-img-style)
982 (goto-char (point-min))
983 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?MJ\\([0-9]+\\);" nil t)
984 (setq code (string-to-int (match-string 2)))
986 (format "<img alt=\"MJ%06d\" src=\"http://mojikiban.ipa.go.jp/search/MJ%06d\"
987 style=\"vertical-align:middle; width: 48px; height: 48px\">"
990 www-format-char-img-style)
993 (goto-char (point-min))
994 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?IU-\\([0-9A-F]+\\);" nil t)
995 (setq code (string-to-int (match-string 2) 16))
997 (format "<img alt=\"u%04x\" src=\"http://glyphwiki.org/glyph/u%04x.100px.png\"
998 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1001 www-format-char-img-style)
1004 (goto-char (point-min))
1005 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?U-i\\([0-9]+\\)\\+\\([0-9A-F]+\\);" nil t)
1006 (setq plane (string-to-int (match-string 2))
1007 code (string-to-int (match-string 3) 16))
1009 (format "<img alt=\"u%04x-itaiji-%03d\" src=\"http://glyphwiki.org/glyph/u%04x-itaiji-%03d.100px.png\"
1010 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1015 www-format-char-img-style)
1018 (goto-char (point-min))
1019 (while (re-search-forward "&\\(G-\\|R-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
1020 (setq code (string-to-int (match-string 2)))
1022 (format "<img alt=\"GT-%05d\" src=\"%s?char=GT-%05d\"
1025 chise-wiki-glyph-cgi-url
1027 www-format-char-img-style)
1030 (goto-char (point-min))
1031 (while (re-search-forward "&\\(G-\\)?GT-K\\([0-9]+\\);" nil t)
1032 (setq code (string-to-int (match-string 2)))
1034 (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\"
1037 chise-wiki-glyph-cgi-url
1039 www-format-char-img-style)
1042 (goto-char (point-min))
1043 (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
1044 (setq code (string-to-int (match-string 1) 16))
1046 (format "<img alt=\"B-%04X\" src=\"%s?char=B-%04X\"
1049 chise-wiki-glyph-cgi-url
1051 www-format-char-img-style)
1054 (goto-char (point-min))
1055 (while (re-search-forward "&\\(G-\\|g2-\\|R-\\)?CDP-\\([0-9A-F]+\\);" nil t)
1056 (setq code (string-to-int (match-string 2) 16))
1058 (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
1061 chise-wiki-glyph-cgi-url
1063 www-format-char-img-style)
1066 (goto-char (point-min))
1067 (while (re-search-forward "&RUI6-\\([0-9A-F]+\\);" nil t)
1068 (setq code (string-to-int (match-string 1) 16))
1070 (format "<img alt=\"RUI6-%04X\" src=\"%s?char=RUI6-%04X\"
1071 style=\"vertical-align:middle\">"
1073 chise-wiki-glyph-cgi-url
1075 www-format-char-img-style)
1078 (goto-char (point-min))
1079 (while (re-search-forward "&hanaJU\\+\\([0-9A-F]+\\);" nil t)
1080 (setq code (string-to-int (match-string 1) 16))
1082 (format "<img alt=\"hanaJU+%04X\" src=\"%s?char=hana-JU+%04X\"
1083 style=\"vertical-align:middle\">"
1085 chise-wiki-glyph-cgi-url
1087 www-format-char-img-style)
1090 (goto-char (point-min))
1091 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\|R-\\)?\\(UU\\+\\|U-\\)\\([0-9A-F]+\\);" nil t)
1092 (setq code (string-to-int (match-string 3) 16))
1094 (format "<img alt=\"UU+%04X\" src=\"http://www.unicode.org/cgi-bin/refglyph?24-%04X\"
1095 style=\"vertical-align:middle\">"
1098 www-format-char-img-style)
1101 (goto-char (point-min))
1102 (while (re-search-forward "&MCS-\\([0-9A-F]+\\);" nil t)
1103 (setq code (string-to-int (match-string 1) 16))
1104 (setq start (match-beginning 0)
1106 (setq char (decode-char 'system-char-id code))
1108 ((and (setq variants
1109 (or (www-get-feature-value char '->subsumptive)
1110 (www-get-feature-value char '->denotational)))
1112 (while (and variants
1113 (setq ret (www-format-encode-string
1114 (char-to-string (car variants))))
1115 (string-match "&MCS-\\([0-9A-F]+\\);" ret))
1116 (setq variants (cdr variants)))
1118 (unless (string-match "&MCS-\\([0-9A-F]+\\);" ret)
1120 (delete-region start end)
1123 ((setq ret (or (www-get-feature-value char 'ideographic-combination)
1124 (www-get-feature-value char 'ideographic-structure)))
1129 (if (characterp (setq rret (find-char ch)))
1132 (www-format-encode-string
1133 (char-to-string ch) without-tags)
1134 (www-format-encode-string
1135 (format "%S" ch) without-tags)))
1139 (delete-region start end)
1143 ;; (goto-char (point-min))
1144 ;; (while (search-forward ">-" nil t)
1145 ;; (replace-match "&GT-" t 'literal))
1148 (defun www-html-display-text (text)
1152 (goto-char (point-min))
1153 (while (search-forward "<" nil t)
1154 (replace-match "<" nil t))
1155 (goto-char (point-min))
1156 (while (search-forward ">" nil t)
1157 (replace-match ">" nil t))
1158 (goto-char (point-min))
1159 (while (re-search-forward "\\[\\[\\([^]|[]+\\)|\\([^][]+\\)\\]\\]" nil t)
1161 (format "<a href=\"%s\">%s</a>"
1165 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
1166 (goto-char (point-min))
1167 (while (search-forward ">-" nil t)
1168 (replace-match "&GT-" nil t))
1171 (defun www-html-display-paragraph (text)
1173 (www-html-display-text text)
1180 (defvar coded-charset-GlyphWiki-id-alist
1181 '((=ucs-var-001 "u" 4 x "-var-001")
1182 (=ucs-var-002 "u" 4 x "-var-002")
1183 (=ucs-var-003 "u" 4 x "-var-003")
1184 (=ucs-itaiji-001 "u" 4 x "-itaiji-001")
1185 (=ucs-itaiji-002 "u" 4 x "-itaiji-002")
1186 (=ucs-itaiji-003 "u" 4 x "-itaiji-003")
1187 (=ucs-itaiji-084 "u" 4 x "-itaiji-084")
1189 (=adobe-japan1-0 "aj1-" 5 d nil)
1190 (=adobe-japan1-1 "aj1-" 5 d nil)
1191 (=adobe-japan1-2 "aj1-" 5 d nil)
1192 (=adobe-japan1-3 "aj1-" 5 d nil)
1193 (=adobe-japan1-4 "aj1-" 5 d nil)
1194 (=adobe-japan1-5 "aj1-" 5 d nil)
1195 (=adobe-japan1-6 "aj1-" 5 d nil)
1196 (==adobe-japan1-0 "aj1-" 5 d nil)
1197 (==adobe-japan1-1 "aj1-" 5 d nil)
1198 (==adobe-japan1-2 "aj1-" 5 d nil)
1199 (==adobe-japan1-3 "aj1-" 5 d nil)
1200 (==adobe-japan1-4 "aj1-" 5 d nil)
1201 (==adobe-japan1-5 "aj1-" 5 d nil)
1202 (==adobe-japan1-6 "aj1-" 5 d nil)
1203 (===adobe-japan1-0 "aj1-" 5 d nil)
1204 (===adobe-japan1-1 "aj1-" 5 d nil)
1205 (===adobe-japan1-2 "aj1-" 5 d nil)
1206 (===adobe-japan1-3 "aj1-" 5 d nil)
1207 (===adobe-japan1-4 "aj1-" 5 d nil)
1208 (===adobe-japan1-5 "aj1-" 5 d nil)
1209 (===adobe-japan1-6 "aj1-" 5 d nil)
1210 (=decomposition@cid)
1211 (=decomposition@hanyo-denshi)
1212 (=hanyo-denshi/ks "koseki-" 6 d nil)
1213 (=>>hanyo-denshi/ks "koseki-" 6 d nil)
1214 (=koseki "koseki-" 6 d nil)
1215 (=ucs@jis "u" 4 x nil)
1216 (==ucs@jis "u" 4 x nil)
1217 (==ucs@iso "u" 4 x nil)
1218 (===ucs@jis "u" 4 x nil)
1219 (=ucs@cns "u" 4 x "-t")
1220 (==ucs@cns "u" 4 x "-t")
1221 (=jis-x0212 "jsp-" 4 x nil)
1222 (=jis-x0213-1@2000 "jx1-2000-" 4 x nil)
1223 (=jis-x0213-1@2004 "jx1-2004-" 4 x nil)
1224 (=jis-x0213-2 "jx2-" 4 x nil)
1226 (=daikanwa "dkw-" 5 d nil)
1227 (==daikanwa "dkw-" 5 d nil)
1228 (===daikanwa "dkw-" 5 d nil)
1229 (=gt-k "gt-k" 5 d nil)
1230 (=jef-china3 "jc3-" 4 x nil)
1231 (=big5 "b-" 4 x nil)
1232 (=ucs@ks "u" 4 x "-k")
1233 (==ucs@ks "u" 4 x "-k")
1234 (===ucs@ks "u" 4 x "-k")
1235 (=ks-x1001 "k0-" 4 x nil)
1236 (=jis-x0208@1978/1pr "j78-" 4 x nil)
1237 (=jis-x0208@1978/-4pr "j78-" 4 x nil)
1238 (=jis-x0208@1978 "j78-" 4 x nil)
1239 (=>>>jis-x0208@1978 "j78-" 4 x nil)
1240 (=>>jis-x0208@1978 "j78-" 4 x nil)
1241 (=+>jis-x0208@1978 "j78-" 4 x nil)
1242 (=ucs@JP "u" 4 x nil)
1243 (=ucs@gb "u" 4 x "-g")
1244 (=ucs@iso "u" 4 x "-u")
1245 (=ucs@unicode "u" 4 x "-us")
1246 (=big5-cdp "cdp-" 4 x nil)
1247 (=>>big5-cdp "cdp-" 4 x nil)
1248 (=cns11643-1 "c1-" 4 x nil)
1249 (=cns11643-2 "c2-" 4 x nil)
1250 (=cns11643-3 "c3-" 4 x nil)
1251 (=cns11643-4 "c4-" 4 x nil)
1252 (=cns11643-5 "c5-" 4 x nil)
1253 (=cns11643-6 "c6-" 4 x nil)
1254 (=cns11643-7 "c7-" 4 x nil)
1255 (=jis-x0208 "j90-" 4 x nil)
1256 (=>>>jis-x0208 "j90-" 4 x nil)
1257 (=>>jis-x0208 "j90-" 4 x nil)
1258 (=+>jis-x0208 "j90-" 4 x nil)
1259 (=jis-x0208@1990 "j90-" 4 x nil)
1260 (=>>>jis-x0208@1990 "j90-" 4 x nil)
1261 (=>>jis-x0208@1990 "j90-" 4 x nil)
1262 (=+>jis-x0208@1990 "j90-" 4 x nil)
1263 (=jis-x0208@1983 "j83-" 4 x nil)
1264 (=>>>jis-x0208@1983 "j83-" 4 x nil)
1265 (=>>jis-x0208@1983 "j83-" 4 x nil)
1266 (=+>jis-x0208@1983 "j83-" 4 x nil)
1267 (=cbeta "cb" 5 d nil)
1268 (=>>daikanwa "dkw-" 5 d nil)
1269 (=big5-cdp-var-3 "cdp-" 4 x "-var-3")
1270 (=big5-cdp-var-5 "cdp-" 4 x "-var-5")
1273 (defun char-GlyphWiki-id (char)
1274 (let ((rest coded-charset-GlyphWiki-id-alist)
1277 (setq spec (pop rest))
1278 (null (setq ret (char-feature char (car spec))))))
1282 (mapconcat #'char-GlyphWiki-id ret "-"))
1283 (and (memq (car spec) '(=ucs@unicode '=ucs@iso))
1285 ((and (or (encode-char char '=jis-x0208@1990)
1286 (encode-char char '=jis-x0212)
1287 (encode-char char '=jis-x0213-1)
1288 (encode-char char '=jis-x0213-2))
1289 (setq code (encode-char char '=ucs@jis)))
1290 (format "u%04x" code)
1292 ((and (or (encode-char char '=gb2312)
1293 (encode-char char '=gb12345))
1294 (setq code (encode-char char '=ucs@gb)))
1295 (format "u%04x-g" code)
1297 ((and (or (encode-char char '=cns11643-1)
1298 (encode-char char '=cns11643-2)
1299 (encode-char char '=cns11643-3)
1300 (encode-char char '=cns11643-4)
1301 (encode-char char '=cns11643-5)
1302 (encode-char char '=cns11643-6)
1303 (encode-char char '=cns11643-7))
1304 (setq code (encode-char char '=ucs@cns)))
1305 (format "u%04x-t" code)
1307 ((and (encode-char char '=ks-x1001)
1308 (setq code (encode-char char '=ucs@ks)))
1309 (format "u%04x-k" code)
1311 (format (format "%s%%0%d%s%s"
1315 (or (nth 4 spec) ""))
1322 (provide 'cwiki-common)
1324 ;;; cwiki-common.el ends here