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 '(==cns11643-1 "R-C1-" 4 X)
813 '(==cns11643-2 "R-C2-" 4 X)
814 '(==cns11643-3 "R-C3-" 4 X)
815 '(==cns11643-4 "R-C4-" 4 X)
816 '(==cns11643-5 "R-C5-" 4 X)
817 '(==cns11643-6 "R-C6-" 4 X)
818 '(==cns11643-7 "R-C7-" 4 X)
819 '(=hanziku-1 "HZK01-" 4 X)
820 '(=hanziku-2 "HZK02-" 4 X)
821 '(=hanziku-3 "HZK03-" 4 X)
822 '(=hanziku-4 "HZK04-" 4 X)
823 '(=hanziku-5 "HZK05-" 4 X)
824 '(=hanziku-6 "HZK06-" 4 X)
825 '(=hanziku-7 "HZK07-" 4 X)
826 '(=hanziku-8 "HZK08-" 4 X)
827 '(=hanziku-9 "HZK09-" 4 X)
828 '(=hanziku-10 "HZK10-" 4 X)
829 '(=hanziku-11 "HZK11-" 4 X)
830 '(=hanziku-12 "HZK12-" 4 X)
832 '(=daikanwa "M-" 5 d)
833 coded-charset-entity-reference-alist)))
834 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
836 (goto-char (point-min))
837 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\)?CB\\([0-9]+\\);" nil t)
838 (setq code (string-to-int (match-string 2)))
840 (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
843 chise-wiki-bitmap-glyphs-url
845 www-format-char-img-style)
848 (goto-char (point-min))
849 (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)
850 (setq plane (match-string 2)
851 code (string-to-int (match-string 3) 16))
853 (format "<img alt=\"J%s-%04X\" src=\"%s/JIS-%s/%02d-%02d.gif\"
856 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-\\)?J0-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
865 (setq code (string-to-int (match-string 2) 16))
867 (format "<img alt=\"J0-%04X\" src=\"%s/JIS-90/%02d-%02d.gif\"
870 chise-wiki-bitmap-glyphs-url
872 (- (logand code 255) 32)
873 www-format-char-img-style)
876 (goto-char (point-min))
877 (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)
878 (setq plane (match-string 2)
879 code (string-to-int (match-string 3) 16))
881 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%02d%02d.png\"
884 chise-wiki-bitmap-glyphs-url
887 (- (logand code 255) 32)
888 www-format-char-img-style)
891 (goto-char (point-min))
892 (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)
893 (setq plane (match-string 2)
894 code (string-to-int (match-string 3) 16))
896 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%04X.png\"
899 chise-wiki-bitmap-glyphs-url
901 www-format-char-img-style)
904 (goto-char (point-min))
905 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-KS-\\([0-9]+\\);" nil t)
906 (setq code (string-to-int (match-string 2)))
908 (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/KS%06d.png\"
909 style=\"vertical-align:middle\">"
911 chise-wiki-bitmap-glyphs-url
913 www-format-char-img-style)
916 (goto-char (point-min))
917 (while (re-search-forward "&G\\([01]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
918 (setq plane (string-to-int (match-string 1))
919 code (string-to-int (match-string 2) 16))
921 (format "<img alt=\"GB%d-%04X\" src=\"%s/GB%d/%02d-%02d.gif\"
924 chise-wiki-bitmap-glyphs-url
927 (- (logand code 255) 32)
928 www-format-char-img-style)
931 (goto-char (point-min))
932 (while (re-search-forward "&\\(R-\\)?C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
933 (setq plane (string-to-int (match-string 2))
934 code (string-to-int (match-string 3) 16))
936 (format "<img alt=\"CNS%d-%04X\" src=\"%s/CNS%d/%04X.gif\"
939 chise-wiki-bitmap-glyphs-url
941 www-format-char-img-style)
944 (goto-char (point-min))
945 (while (re-search-forward "&\\(R-\\)?JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
946 (setq code (string-to-int (match-string 2) 16))
948 (format "<img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">"
952 (goto-char (point-min))
953 (while (re-search-forward "&\\(A-\\)?ZOB-\\([0-9]+\\);" nil t)
954 (setq code (string-to-int (match-string 2)))
956 (format "<img alt=\"ZOB-%04d\" src=\"%s/ZOB-1968/%04d.png\"
957 style=\"vertical-align:middle\">"
959 chise-wiki-bitmap-glyphs-url
961 www-format-char-img-style)
964 (goto-char (point-min))
965 (while (re-search-forward "&HNG\\([0-9]+\\)-\\([0-9][0-9][0-9][0-9]\\)\\([0-9]\\);" nil t)
966 (setq plane (match-string 1)
967 code (string-to-int (match-string 2))
968 subcode (string-to-int (match-string 3)))
972 (char-to-string (decode-char 'ascii (+ 96 subcode)))))
975 "<img alt=\"HNG%s-%04d%s\" src=\"%s/%s/%04d%s.png\"
976 style=\"vertical-align:middle; width: 48px; height: 48px\">"
978 chise-wiki-hng-bitmap-glyphs-url
980 www-format-char-img-style)
983 (goto-char (point-min))
984 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?AJ1-\\([0-9]+\\);" nil t)
985 (setq code (string-to-int (match-string 2)))
987 (format "<img alt=\"AJ1-%05d\" src=\"%s/IVD/AdobeJapan1/CID+%d.png\"
988 style=\"vertical-align:middle\">"
990 chise-wiki-bitmap-glyphs-url
992 www-format-char-img-style)
995 (goto-char (point-min))
996 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?MJ\\([0-9]+\\);" nil t)
997 (setq code (string-to-int (match-string 2)))
999 (format "<img alt=\"MJ%06d\" src=\"http://mojikiban.ipa.go.jp/search/MJ%06d\"
1000 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1003 www-format-char-img-style)
1006 (goto-char (point-min))
1007 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?IU[+-]\\([0-9A-F]+\\);" nil t)
1008 (setq code (string-to-int (match-string 2) 16))
1010 (format "<img alt=\"u%04x\" src=\"http://glyphwiki.org/glyph/u%04x.100px.png\"
1011 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1014 www-format-char-img-style)
1017 (goto-char (point-min))
1018 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?U-i\\([0-9]+\\)\\+\\([0-9A-F]+\\);" nil t)
1019 (setq plane (string-to-int (match-string 2))
1020 code (string-to-int (match-string 3) 16))
1022 (format "<img alt=\"u%04x-itaiji-%03d\" src=\"http://glyphwiki.org/glyph/u%04x-itaiji-%03d.100px.png\"
1023 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1028 www-format-char-img-style)
1031 (goto-char (point-min))
1032 (while (re-search-forward "&\\(A-\\|G-\\|R-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
1033 (setq code (string-to-int (match-string 2)))
1035 (format "<img alt=\"GT-%05d\" src=\"%s?char=GT-%05d\"
1038 chise-wiki-glyph-cgi-url
1040 www-format-char-img-style)
1043 (goto-char (point-min))
1044 (while (re-search-forward "&\\(G-\\)?GT-K\\([0-9]+\\);" nil t)
1045 (setq code (string-to-int (match-string 2)))
1047 (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\"
1050 chise-wiki-glyph-cgi-url
1052 www-format-char-img-style)
1055 (goto-char (point-min))
1056 (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
1057 (setq code (string-to-int (match-string 1) 16))
1059 (format "<img alt=\"B-%04X\" src=\"%s?char=B-%04X\"
1062 chise-wiki-glyph-cgi-url
1064 www-format-char-img-style)
1067 (goto-char (point-min))
1068 (while (re-search-forward "&\\(G-\\|g2-\\|R-\\)?CDP-\\([0-9A-F]+\\);" nil t)
1069 (setq code (string-to-int (match-string 2) 16))
1071 (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
1074 chise-wiki-glyph-cgi-url
1076 www-format-char-img-style)
1079 (goto-char (point-min))
1080 (while (re-search-forward
1081 "&\\(I-\\)?HZK\\(0[1-9]\\|1[0-2]\\)-\\([0-9A-F]+\\);" nil t)
1082 (setq plane (match-string 2)
1083 code (string-to-int (match-string 3) 16))
1085 (format "<img alt=\"HZK%s-%04X\" src=\"%s?char=HZK%s-%04X\"
1089 chise-wiki-glyph-cgi-url
1092 www-format-char-img-style)
1095 (goto-char (point-min))
1096 (while (re-search-forward "&RUI6-\\([0-9A-F]+\\);" nil t)
1097 (setq code (string-to-int (match-string 1) 16))
1099 (format "<img alt=\"RUI6-%04X\" src=\"%s?char=RUI6-%04X\"
1100 style=\"vertical-align:middle\">"
1102 chise-wiki-glyph-cgi-url
1104 www-format-char-img-style)
1107 (goto-char (point-min))
1108 (while (re-search-forward "&hanaJU\\+\\([0-9A-F]+\\);" nil t)
1109 (setq code (string-to-int (match-string 1) 16))
1111 (format "<img alt=\"hanaJU+%04X\" src=\"%s?char=hana-JU+%04X\"
1112 style=\"vertical-align:middle\">"
1114 chise-wiki-glyph-cgi-url
1116 www-format-char-img-style)
1119 (goto-char (point-min))
1120 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\|R-\\)?\\(UU\\+\\|U-\\)\\([0-9A-F]+\\);" nil t)
1121 (setq code (string-to-int (match-string 3) 16))
1123 (format "<img alt=\"UU+%04X\" src=\"http://www.unicode.org/cgi-bin/refglyph?24-%04X\"
1124 style=\"vertical-align:middle\">"
1127 www-format-char-img-style)
1130 (goto-char (point-min))
1131 (while (re-search-forward "&MCS-\\([0-9A-F]+\\);" nil t)
1132 (setq code (string-to-int (match-string 1) 16))
1133 (setq start (match-beginning 0)
1135 (setq char (decode-char 'system-char-id code))
1137 ((and (setq variants
1138 (or (www-get-feature-value char '->subsumptive)
1139 (www-get-feature-value char '->denotational)))
1141 (while (and variants
1142 (setq ret (www-format-encode-string
1143 (char-to-string (car variants))))
1144 (string-match "&MCS-\\([0-9A-F]+\\);" ret))
1145 (setq variants (cdr variants)))
1147 (unless (string-match "&MCS-\\([0-9A-F]+\\);" ret)
1149 (delete-region start end)
1152 ((setq ret (or (www-get-feature-value char 'ideographic-combination)
1153 (www-get-feature-value char 'ideographic-structure)))
1158 (if (characterp (setq rret (find-char ch)))
1161 (www-format-encode-string
1162 (char-to-string ch) without-tags)
1163 (www-format-encode-string
1164 (format "%S" ch) without-tags)))
1168 (delete-region start end)
1172 ;; (goto-char (point-min))
1173 ;; (while (search-forward ">-" nil t)
1174 ;; (replace-match "&GT-" t 'literal))
1177 (defun www-html-display-text (text)
1181 (goto-char (point-min))
1182 (while (search-forward "<" nil t)
1183 (replace-match "<" nil t))
1184 (goto-char (point-min))
1185 (while (search-forward ">" nil t)
1186 (replace-match ">" nil t))
1187 (goto-char (point-min))
1188 (while (re-search-forward "\\[\\[\\([^]|[]+\\)|\\([^][]+\\)\\]\\]" nil t)
1190 (format "<a href=\"%s\">%s</a>"
1194 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
1195 (goto-char (point-min))
1196 (while (search-forward ">-" nil t)
1197 (replace-match "&GT-" nil t))
1200 (defun www-html-display-paragraph (text)
1202 (www-html-display-text text)
1209 (defvar coded-charset-GlyphWiki-id-alist
1210 '((=ucs-var-001 "u" 4 x "-var-001")
1211 (=ucs-var-002 "u" 4 x "-var-002")
1212 (=ucs-var-003 "u" 4 x "-var-003")
1213 (=ucs-itaiji-001 "u" 4 x "-itaiji-001")
1214 (=ucs-itaiji-002 "u" 4 x "-itaiji-002")
1215 (=ucs-itaiji-003 "u" 4 x "-itaiji-003")
1216 (=ucs-itaiji-084 "u" 4 x "-itaiji-084")
1218 (=adobe-japan1-0 "aj1-" 5 d nil)
1219 (=adobe-japan1-1 "aj1-" 5 d nil)
1220 (=adobe-japan1-2 "aj1-" 5 d nil)
1221 (=adobe-japan1-3 "aj1-" 5 d nil)
1222 (=adobe-japan1-4 "aj1-" 5 d nil)
1223 (=adobe-japan1-5 "aj1-" 5 d nil)
1224 (=adobe-japan1-6 "aj1-" 5 d nil)
1225 (==adobe-japan1-0 "aj1-" 5 d nil)
1226 (==adobe-japan1-1 "aj1-" 5 d nil)
1227 (==adobe-japan1-2 "aj1-" 5 d nil)
1228 (==adobe-japan1-3 "aj1-" 5 d nil)
1229 (==adobe-japan1-4 "aj1-" 5 d nil)
1230 (==adobe-japan1-5 "aj1-" 5 d nil)
1231 (==adobe-japan1-6 "aj1-" 5 d nil)
1232 (===adobe-japan1-0 "aj1-" 5 d nil)
1233 (===adobe-japan1-1 "aj1-" 5 d nil)
1234 (===adobe-japan1-2 "aj1-" 5 d nil)
1235 (===adobe-japan1-3 "aj1-" 5 d nil)
1236 (===adobe-japan1-4 "aj1-" 5 d nil)
1237 (===adobe-japan1-5 "aj1-" 5 d nil)
1238 (===adobe-japan1-6 "aj1-" 5 d nil)
1239 (=decomposition@cid)
1240 (=decomposition@hanyo-denshi)
1241 (=hanyo-denshi/ks "koseki-" 6 d nil)
1242 (=>>hanyo-denshi/ks "koseki-" 6 d nil)
1243 (=koseki "koseki-" 6 d nil)
1244 (=ucs@jis "u" 4 x nil)
1245 (==ucs@jis "u" 4 x nil)
1246 (==ucs@iso "u" 4 x nil)
1247 (===ucs@jis "u" 4 x nil)
1248 (=ucs@cns "u" 4 x "-t")
1249 (==ucs@cns "u" 4 x "-t")
1250 (=jis-x0212 "jsp-" 4 x nil)
1251 (=jis-x0213-1@2000 "jx1-2000-" 4 x nil)
1252 (=jis-x0213-1@2004 "jx1-2004-" 4 x nil)
1253 (=jis-x0213-2 "jx2-" 4 x nil)
1255 (=daikanwa "dkw-" 5 d nil)
1256 (==daikanwa "dkw-" 5 d nil)
1257 (===daikanwa "dkw-" 5 d nil)
1258 (=gt-k "gt-k" 5 d nil)
1259 (=jef-china3 "jc3-" 4 x nil)
1260 (=big5 "b-" 4 x nil)
1261 (=ucs@ks "u" 4 x "-k")
1262 (==ucs@ks "u" 4 x "-k")
1263 (===ucs@ks "u" 4 x "-k")
1264 (=ks-x1001 "k0-" 4 x nil)
1265 (=jis-x0208@1978/1pr "j78-" 4 x nil)
1266 (=jis-x0208@1978/-4pr "j78-" 4 x nil)
1267 (=jis-x0208@1978 "j78-" 4 x nil)
1268 (=>>>jis-x0208@1978 "j78-" 4 x nil)
1269 (=>>jis-x0208@1978 "j78-" 4 x nil)
1270 (=+>jis-x0208@1978 "j78-" 4 x nil)
1271 (=ucs@JP "u" 4 x nil)
1272 (=ucs@gb "u" 4 x "-g")
1273 (=ucs@iso "u" 4 x "-u")
1274 (=ucs@unicode "u" 4 x "-us")
1275 (=big5-cdp "cdp-" 4 x nil)
1276 (=>>big5-cdp "cdp-" 4 x nil)
1277 (=cns11643-1 "c1-" 4 x nil)
1278 (=cns11643-2 "c2-" 4 x nil)
1279 (=cns11643-3 "c3-" 4 x nil)
1280 (=cns11643-4 "c4-" 4 x nil)
1281 (=cns11643-5 "c5-" 4 x nil)
1282 (=cns11643-6 "c6-" 4 x nil)
1283 (=cns11643-7 "c7-" 4 x nil)
1284 (=jis-x0208 "j90-" 4 x nil)
1285 (=>>>jis-x0208 "j90-" 4 x nil)
1286 (=>>jis-x0208 "j90-" 4 x nil)
1287 (=+>jis-x0208 "j90-" 4 x nil)
1288 (=jis-x0208@1990 "j90-" 4 x nil)
1289 (=>>>jis-x0208@1990 "j90-" 4 x nil)
1290 (=>>jis-x0208@1990 "j90-" 4 x nil)
1291 (=+>jis-x0208@1990 "j90-" 4 x nil)
1292 (=jis-x0208@1983 "j83-" 4 x nil)
1293 (=>>>jis-x0208@1983 "j83-" 4 x nil)
1294 (=>>jis-x0208@1983 "j83-" 4 x nil)
1295 (=+>jis-x0208@1983 "j83-" 4 x nil)
1296 (=cbeta "cb" 5 d nil)
1297 (=>>daikanwa "dkw-" 5 d nil)
1298 (=big5-cdp-var-3 "cdp-" 4 x "-var-3")
1299 (=big5-cdp-var-5 "cdp-" 4 x "-var-5")
1302 (defun char-GlyphWiki-id (char)
1303 (let ((rest coded-charset-GlyphWiki-id-alist)
1306 (setq spec (pop rest))
1307 (null (setq ret (char-feature char (car spec))))))
1311 (mapconcat #'char-GlyphWiki-id ret "-"))
1312 (and (memq (car spec) '(=ucs@unicode '=ucs@iso))
1314 ((and (or (encode-char char '=jis-x0208@1990)
1315 (encode-char char '=jis-x0212)
1316 (encode-char char '=jis-x0213-1)
1317 (encode-char char '=jis-x0213-2))
1318 (setq code (encode-char char '=ucs@jis)))
1319 (format "u%04x" code)
1321 ((and (or (encode-char char '=gb2312)
1322 (encode-char char '=gb12345))
1323 (setq code (encode-char char '=ucs@gb)))
1324 (format "u%04x-g" code)
1326 ((and (or (encode-char char '=cns11643-1)
1327 (encode-char char '=cns11643-2)
1328 (encode-char char '=cns11643-3)
1329 (encode-char char '=cns11643-4)
1330 (encode-char char '=cns11643-5)
1331 (encode-char char '=cns11643-6)
1332 (encode-char char '=cns11643-7))
1333 (setq code (encode-char char '=ucs@cns)))
1334 (format "u%04x-t" code)
1336 ((and (encode-char char '=ks-x1001)
1337 (setq code (encode-char char '=ucs@ks)))
1338 (format "u%04x-k" code)
1340 (format (format "%s%%0%d%s%s"
1344 (or (nth 4 spec) ""))
1351 (provide 'cwiki-common)
1353 ;;; cwiki-common.el ends here