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
91 (defun decode-uri-string (string &optional coding-system)
92 (if (> (length string) 0)
96 (mapconcat (lambda (char)
99 (char-to-string char)))
101 (while (string-match "%\\([0-9A-F][0-9A-F]\\)" string i)
102 (setq dest (concat dest
103 (substring string i (match-beginning 0))
106 (string-to-int (match-string 1 string) 16))))
108 (decode-coding-string
109 (concat dest (substring string i))
112 (defun www-feature-type (feature-name)
113 (or (char-feature-property feature-name 'type)
114 (let ((str (symbol-name feature-name)))
116 ((string-match "\\*note\\(@[^*]+\\)?$" str)
118 ((string-match "\\*sources\\(@[^*]+\\)?$" str)
120 ((string-match "\\*" str)
122 ((string-match "^\\(->\\|<-\\)" str)
124 ((string-match "^ideographic-structure\\(@\\|$\\)" str)
128 (defun www-feature-format (feature-name)
129 (or (char-feature-property feature-name 'presentation-format)
130 (char-feature-property feature-name 'format)
132 (setq fn feature-name)
133 (while (and (setq parent (char-feature-name-parent fn))
135 (char-feature-property
139 '((name) " : " (value))))
141 (defun www-feature-value-format (feature-name)
142 (or (char-feature-property feature-name 'value-presentation-format)
143 (char-feature-property feature-name 'value-format)
145 (setq fn feature-name)
146 (while (and (setq parent (char-feature-name-parent fn))
148 (or (char-feature-property
149 parent 'value-presentation-format)
150 (char-feature-property
151 parent 'value-format)))))
154 (let ((type (www-feature-type feature-name)))
155 (cond ((eq type 'relation)
157 ((eq type 'structure)
158 'space-separated-ids)
162 (if (find-charset feature-name)
163 (if (and (= (charset-dimension feature-name) 2)
164 (= (charset-chars feature-name) 94))
166 " (" (decimal) ") <" (ku-ten) "> " (prev-char) (next-char))
167 '("0x" (HEX) " (" (decimal) ") " (prev-char) (next-char))))
170 (defun char-feature-name-at-domain (feature-name domain)
172 (let ((name (symbol-name feature-name)))
174 ((string-match "@[^*]+$" name)
175 (intern (format "%s/%s" name domain))
178 (intern (format "%s@%s" name domain))
182 (defun char-feature-name-parent (feature-name)
183 (let ((name (symbol-name feature-name)))
184 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
185 (intern (substring name 0 (car (last (match-data) 2)))))))
187 (defun char-feature-name-domain (feature-name)
188 (let ((name (symbol-name feature-name)))
189 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
190 (intern (substring name (1+ (match-beginning 0)))))))
192 (defun char-feature-name-sans-versions (feature)
193 (let ((feature-name (symbol-name feature)))
194 (if (string-match "[@/]\\$rev=latest$" feature-name)
195 (intern (substring feature-name 0 (match-beginning 0)))
198 (defun est-object-genre (object)
199 (if (characterp object)
201 (concord-object-genre object)))
203 (defun www-get-feature-value (object feature)
204 (let ((latest-feature (char-feature-name-at-domain feature '$rev=latest)))
207 (mount-char-attribute-table latest-feature)
208 (or (char-feature object latest-feature)
209 (char-feature object feature))
212 (or (condition-case nil
213 (concord-object-get object latest-feature)
216 (concord-object-get object feature)
220 (defun get-previous-code-point (ccs code)
221 (let ((chars (charset-chars ccs))
222 (dim (charset-dimension ccs))
224 mask byte-min byte-max
247 (setq bytes (make-vector dim 0))
249 (aset bytes i (logand (lsh code (* i -8)) mask))
252 (while (and (< i dim)
254 (aset bytes i (1- (aref bytes i)))
255 (< (aref bytes i) byte-min)))
256 (aset bytes i byte-max)
259 (setq dest (aref bytes 0)
262 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
266 (defun get-next-code-point (ccs code)
267 (let ((chars (charset-chars ccs))
268 (dim (charset-dimension ccs))
270 mask byte-min byte-max
293 (setq bytes (make-vector dim 0))
295 (aset bytes i (logand (lsh code (* i -8)) mask))
298 (while (and (< i dim)
300 (aset bytes i (1+ (aref bytes i)))
301 (> (aref bytes i) byte-max)))
302 (aset bytes i byte-min)
305 (setq dest (aref bytes 0)
308 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
312 (defun find-previous-defined-code-point (ccs code)
313 (let ((i (get-previous-code-point ccs code))
316 ((eq ccs '=jis-x0208)
317 (setq ccs '=jis-x0208@1990))
318 ((eq ccs '=jis-x0213-1)
319 (setq ccs '=jis-x0213-1@2004)))
322 (null (setq char (decode-char ccs i
323 (unless (eq ccs '=ucs)
325 (setq i (get-previous-code-point ccs i)))
328 (defun find-next-defined-code-point (ccs code)
329 (let ((i (get-next-code-point ccs code))
331 (setq max (+ code 1000))
333 ((eq ccs '=jis-x0208)
334 (setq ccs '=jis-x0208@1990))
335 ((eq ccs '=jis-x0213-1)
336 (setq ccs '=jis-x0213-1@2004)))
339 (null (setq char (decode-char ccs i
340 (unless (eq ccs '=ucs)
342 (setq i (get-next-code-point ccs i)))
346 ;;; @ URI representation
349 (defun est-uri-decode-feature-name-body (uri-feature)
350 (let ((len (length uri-feature))
357 (if (eq (aref uri-feature i) ?\.)
358 (if (and (< (+ i 2) len)
359 (eq (aref uri-feature (+ i 2)) ?\.))
362 ((eq (setq ch (aref uri-feature (1+ i))) ?\.)
367 (substring uri-feature i (+ i 3))
373 (char-to-string (aref uri-feature i))
377 (defun est-uri-encode-feature-name-body (feature)
378 (mapconcat (lambda (c)
383 (t (char-to-string c))))
386 (defun www-uri-decode-feature-name (uri-feature)
388 (setq uri-feature (decode-uri-string uri-feature 'utf-8-mcs-er))
390 ((string-match "^from\\." uri-feature)
391 (intern (format "<-%s"
392 (est-uri-decode-feature-name-body
393 (substring uri-feature (match-end 0)))))
395 ((string-match "^to\\." uri-feature)
396 (intern (format "->%s"
397 (est-uri-decode-feature-name-body
398 (substring uri-feature (match-end 0)))))
400 ((string-match "^rep\\." uri-feature)
401 (intern (format "=%s"
402 (est-uri-decode-feature-name-body
403 (substring uri-feature (match-end 0)))))
405 ((string-match "^rep[2i]\\." uri-feature)
406 (intern (format "===%s"
407 (est-uri-decode-feature-name-body
408 (substring uri-feature (match-end 0)))))
410 ((string-match "^g\\." uri-feature)
411 (intern (format "=>>%s"
412 (est-uri-decode-feature-name-body
413 (substring uri-feature (match-end 0)))))
415 ((string-match "^g[i2]\\." uri-feature)
416 (intern (format "==%s"
417 (est-uri-decode-feature-name-body
418 (substring uri-feature (match-end 0)))))
420 ((string-match "^gi\\([0-9]+\\)\\." uri-feature)
421 (intern (format "=>>%s%s"
422 (make-string (string-to-int
423 (match-string 1 uri-feature))
425 (est-uri-decode-feature-name-body
426 (substring uri-feature (match-end 0)))))
428 ((string-match "^o\\." uri-feature)
429 (intern (format "=+>%s"
430 (est-uri-decode-feature-name-body
431 (substring uri-feature (match-end 0)))))
433 ((string-match "^a\\." uri-feature)
434 (intern (format "=>%s"
435 (est-uri-decode-feature-name-body
436 (substring uri-feature (match-end 0)))))
438 ((string-match "^a\\([0-9]+\\)\\." uri-feature)
439 (intern (format "%s>%s"
440 (make-string (string-to-int
441 (match-string 1 uri-feature))
443 (est-uri-decode-feature-name-body
444 (substring uri-feature (match-end 0)))))
446 ((and (setq uri-feature (est-uri-decode-feature-name-body uri-feature))
447 (setq feature (intern (format "=>%s" uri-feature)))
448 (find-charset feature))
450 ((and (setq feature (intern (format "=>>%s" uri-feature)))
451 (find-charset feature))
453 ((and (setq feature (intern (format "=>>>%s" uri-feature)))
454 (find-charset feature))
456 ((and (setq feature (intern (format "=%s" uri-feature)))
457 (find-charset feature))
459 (t (intern uri-feature)))))
461 (defun www-uri-encode-feature-name (feature-name)
462 (setq feature-name (symbol-name feature-name))
464 ((string-match "^=\\+>\\([^=>]+\\)" feature-name)
466 (est-uri-encode-feature-name-body
467 (substring feature-name (match-beginning 1))))
469 ((string-match "^=\\([^=>]+\\)" feature-name)
471 (est-uri-encode-feature-name-body
472 (substring feature-name (match-beginning 1))))
474 ((string-match "^==\\([^=>]+\\)" feature-name)
476 (est-uri-encode-feature-name-body
477 (substring feature-name (match-beginning 1))))
479 ((string-match "^===\\([^=>]+\\)" feature-name)
481 (est-uri-encode-feature-name-body
482 (substring feature-name (match-beginning 1))))
484 ((string-match "^=>>\\([^=>]+\\)" feature-name)
486 (est-uri-encode-feature-name-body
487 (substring feature-name (match-beginning 1))))
489 ((string-match "^=>>>\\([^=>]+\\)" feature-name)
491 (est-uri-encode-feature-name-body
492 (substring feature-name (match-beginning 1))))
494 ((string-match "^=>>\\(>+\\)" feature-name)
496 (length (match-string 1 feature-name))
497 (est-uri-encode-feature-name-body
498 (substring feature-name (match-end 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 (length (match-string 1 feature-name))
508 (est-uri-encode-feature-name-body
509 (substring feature-name (match-end 0))))
511 ((string-match "^->" feature-name)
513 (est-uri-encode-feature-name-body
514 (substring feature-name (match-end 0))))
516 ((string-match "^<-" feature-name)
518 (est-uri-encode-feature-name-body
519 (substring feature-name (match-end 0))))
521 (t (est-uri-encode-feature-name-body feature-name))))
523 (defun www-uri-make-feature-name-url (uri-genre uri-feature-name uri-object)
524 (if est-hide-cgi-mode
525 (format "../feature/%s&%s/%s"
526 uri-feature-name uri-genre uri-object)
527 (format "%s?feature=%s&%s=%s"
528 chise-wiki-view-url uri-feature-name uri-genre uri-object)))
530 (defun www-uri-decode-object (genre char-rep)
533 ((string-match (if est-hide-cgi-mode
534 "\\(%3D\\|=\\|%3A\\|:\\)"
535 "\\(%3A\\|:\\)") char-rep)
536 (setq ccs (substring char-rep 0 (match-beginning 0))
537 cpos (substring char-rep (match-end 0)))
538 (setq ccs (www-uri-decode-feature-name ccs))
539 (setq cpos (est-uri-decode-feature-name-body cpos))
541 ((string-match "^0x" cpos)
543 (string-to-number (substring cpos (match-end 0)) 16))
546 (setq cpos (car (read-from-string
548 cpos file-name-coding-system))))
550 (if (and (eq genre 'character)
552 (decode-char ccs cpos)
553 (concord-decode-object ccs cpos genre))
556 (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er))
558 ((eq genre 'character)
559 (when (= (length char-rep) 1)
563 (concord-decode-object
564 '=id (www-uri-decode-feature-name char-rep) 'feature)
567 (concord-decode-object
568 '=id (car (read-from-string char-rep)) genre)
571 (defun www-uri-encode-object (object)
572 (if (characterp object)
573 (if (encode-char object '=ucs)
576 (format "%%%02X" byte))
577 (encode-coding-string (char-to-string object) 'utf-8-mcs-er)
579 (let ((ccs-list est-coded-charset-priority-list)
582 (setq ccs (pop ccs-list))
583 (not (setq ret (encode-char object ccs 'defined-only)))))
585 (format (if est-hide-cgi-mode
588 (www-uri-encode-feature-name ccs)
590 ((and (setq ccs (car (split-char object)))
591 (setq ret (encode-char object ccs)))
592 (format (if est-hide-cgi-mode
595 (www-uri-encode-feature-name ccs)
598 (format (if est-hide-cgi-mode
599 "system-char-id=0x%X"
600 "system-char-id:0x%X")
601 (encode-char object 'system-char-id))
603 (format (if est-hide-cgi-mode
606 (est-uri-encode-feature-name-body
607 (format "%s" (concord-object-id object))))))
609 (defun est-format-object (object &optional readable)
610 (if (characterp object)
611 (char-to-string object)
612 (let ((ret (or (if readable
613 (or (concord-object-get object 'name)
614 (concord-object-get object '=name)
615 (concord-object-get object 'title)))
616 (concord-object-id object))))
619 (defun www-uri-make-object-url (object &optional uri-object)
620 (if est-hide-cgi-mode
623 (est-object-genre object)
625 (www-uri-encode-object object)))
628 (est-object-genre object)
630 (www-uri-encode-object object)))))
633 ;;; @ Feature name presentation
636 (defun www-format-feature-name-default (feature-name)
640 (symbol-name feature-name)
644 (defun www-format-feature-name-as-metadata (feature-name &optional lang)
645 (let ((str (symbol-name feature-name))
648 ((string-match "\\*[^*]+$" str)
649 (setq base (substring str 0 (match-beginning 0))
650 meta (substring str (match-beginning 0)))
651 (concat (www-format-feature-name* (intern base) lang)
654 (www-format-feature-name-default feature-name)
657 (defun www-format-feature-name-as-rel-to (feature-name)
658 (concat "\u2192" (substring (symbol-name feature-name) 2)))
660 (defun www-format-feature-name-as-rel-from (feature-name)
661 (concat "\u2190" (substring (symbol-name feature-name) 2)))
663 (defun www-format-feature-name-as-CCS (feature-name)
666 (symbol-name feature-name)
668 (dest (upcase (pop rest))))
669 (when (string-match "^=+>*" dest)
670 (setq dest (concat (substring dest 0 (match-end 0))
672 (substring dest (match-end 0)))))
676 (setq dest (concat dest " " (upcase (pop rest)))))
677 (if (string-match "^[0-9]+$" (car rest))
678 (concat dest "-" (car rest))
679 (concat dest " " (upcase (car rest))))
683 (defun www-format-feature-name* (feature-name &optional lang)
684 (let (name fn parent ret)
687 (char-feature-property
689 (intern (format "name@%s" lang))))
690 (char-feature-property
691 feature-name 'name)))
692 ((and (setq name (symbol-name feature-name))
693 (string-match "\\*" name))
694 (www-format-feature-name-as-metadata feature-name lang))
696 (setq fn feature-name)
697 (while (and (setq parent (char-feature-name-parent fn))
700 (char-feature-property
702 (intern (format "name@%s" lang))))
703 (char-feature-property
708 (concat ret (substring (symbol-name feature-name)
709 (length (symbol-name parent)))))
710 ((find-charset feature-name)
711 (www-format-feature-name-as-CCS feature-name))
712 ((string-match "^\\(->\\)" name)
713 (www-format-feature-name-as-rel-to feature-name))
714 ((string-match "^\\(<-\\)" name)
715 (www-format-feature-name-as-rel-from feature-name))
717 (www-format-feature-name-default feature-name)
721 (defun www-format-feature-name (feature-name &optional lang)
722 (www-format-encode-string
723 (www-format-feature-name* feature-name lang)))
729 (defvar www-format-char-img-style "vertical-align:bottom;")
731 (defun www-format-encode-string (string &optional without-tags as-body)
734 (let (plane code subcode start end char variants ret rret)
736 (goto-char (point-min))
737 (while (search-forward "&" nil t)
738 (replace-match "&" nil t)))
739 (goto-char (point-min))
740 (while (search-forward "<" nil t)
741 (replace-match "<" nil t))
742 (goto-char (point-min))
743 (while (search-forward ">" nil t)
744 (replace-match ">" nil t))
746 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
747 (let ((coded-charset-entity-reference-alist
750 '(=hanyo-denshi/ja "HD-JA-" 4 X)
751 '(=hanyo-denshi/jb "HD-JB-" 4 X)
752 '(=hanyo-denshi/jc "HD-JC-" 4 X)
753 '(=hanyo-denshi/jd "HD-JD-" 4 X)
754 '(=hanyo-denshi/ft "HD-FT-" 4 X)
755 '(=hanyo-denshi/ia "HD-IA-" 4 X)
756 '(=hanyo-denshi/ib "HD-IB-" 4 X)
757 '(=hanyo-denshi/hg "HD-HG-" 4 X)
758 '(=hanyo-denshi/ip "HD-IP-" 4 X)
759 '(=hanyo-denshi/jt "HD-JT-" 4 X)
760 '(=hanyo-denshi/ks "HD-KS-" 6 d)
761 '(=>>hanyo-denshi/ja "G-HD-JA-" 4 X)
762 '(=>>hanyo-denshi/jb "G-HD-JB-" 4 X)
763 '(=>>hanyo-denshi/jc "G-HD-JC-" 4 X)
764 '(=>>hanyo-denshi/jd "G-HD-JD-" 4 X)
765 '(=>>hanyo-denshi/ft "G-HD-FT-" 4 X)
766 '(=>>hanyo-denshi/ia "G-HD-IA-" 4 X)
767 '(=>>hanyo-denshi/ib "G-HD-IB-" 4 X)
768 '(=>>hanyo-denshi/hg "G-HD-HG-" 4 X)
769 '(=>>hanyo-denshi/ip "G-HD-IP-" 4 X)
770 '(=>>hanyo-denshi/jt "G-HD-JT-" 4 X)
771 '(=>>hanyo-denshi/ks "G-HD-KS-" 6 d)
772 '(==hanyo-denshi/ja "g2-HD-JA-" 4 X)
773 '(==hanyo-denshi/jb "g2-HD-JB-" 4 X)
774 '(==hanyo-denshi/jc "g2-HD-JC-" 4 X)
775 '(==hanyo-denshi/jd "g2-HD-JD-" 4 X)
776 '(==hanyo-denshi/ft "g2-HD-FT-" 4 X)
777 '(==hanyo-denshi/ia "g2-HD-IA-" 4 X)
778 '(==hanyo-denshi/ib "g2-HD-IB-" 4 X)
779 '(==hanyo-denshi/hg "g2-HD-HG-" 4 X)
780 '(==hanyo-denshi/ip "g2-HD-IP-" 4 X)
781 '(==hanyo-denshi/jt "g2-HD-JT-" 4 X)
782 '(==hanyo-denshi/ks "g2-HD-KS-" 6 d)
783 '(=cns11643-1 "C1-" 4 X)
784 '(=cns11643-2 "C2-" 4 X)
785 '(=cns11643-3 "C3-" 4 X)
786 '(=cns11643-4 "C4-" 4 X)
787 '(=cns11643-5 "C5-" 4 X)
788 '(=cns11643-6 "C6-" 4 X)
789 '(=cns11643-7 "C7-" 4 X)
790 '(=adobe-japan1-6 "AJ1-" 5 d)
791 '(=big5-cdp "CDP-" 4 X)
793 '(=gb12345 "G1-" 4 X)
794 '(=jis-x0208@1990 "J90-" 4 X)
795 '(=jis-x0212 "JSP-" 4 X)
797 '(=jis-x0208@1997 "J97-" 4 X)
798 '(=jis-x0208@1978 "J78-" 4 X)
799 '(=jis-x0208@1983 "J83-" 4 X)
800 '(=ruimoku-v6 "RUI6-" 4 X)
801 '(=zinbun-oracle "ZOB-" 4 d)
802 '(=jef-china3 "JC3-" 4 X)
803 '(=ucs@unicode "UU+" 4 X)
804 '(=ucs@JP/hanazono "hanaJU+" 4 X)
805 '(=daikanwa "M-" 5 d)
806 '(==cns11643-1 "R-C1-" 4 X)
807 '(==cns11643-2 "R-C2-" 4 X)
808 '(==cns11643-3 "R-C3-" 4 X)
809 '(==cns11643-4 "R-C4-" 4 X)
810 '(==cns11643-5 "R-C5-" 4 X)
811 '(==cns11643-6 "R-C6-" 4 X)
812 '(==cns11643-7 "R-C7-" 4 X)
813 coded-charset-entity-reference-alist)))
814 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
816 (goto-char (point-min))
817 (while (re-search-forward "&CB\\([0-9]+\\);" nil t)
818 (setq code (string-to-int (match-string 1)))
820 (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
823 chise-wiki-bitmap-glyphs-url
825 www-format-char-img-style)
828 (goto-char (point-min))
829 (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)
830 (setq plane (match-string 2)
831 code (string-to-int (match-string 3) 16))
833 (format "<img alt=\"J%s-%04X\" src=\"%s/JIS-%s/%02d-%02d.gif\"
836 chise-wiki-bitmap-glyphs-url
839 (- (logand code 255) 32)
840 www-format-char-img-style)
843 (goto-char (point-min))
844 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?J0-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
845 (setq code (string-to-int (match-string 2) 16))
847 (format "<img alt=\"J0-%04X\" src=\"%s/JIS-90/%02d-%02d.gif\"
850 chise-wiki-bitmap-glyphs-url
852 (- (logand code 255) 32)
853 www-format-char-img-style)
856 (goto-char (point-min))
857 (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)
858 (setq plane (match-string 2)
859 code (string-to-int (match-string 3) 16))
861 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%02d%02d.png\"
864 chise-wiki-bitmap-glyphs-url
867 (- (logand code 255) 32)
868 www-format-char-img-style)
871 (goto-char (point-min))
872 (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)
873 (setq plane (match-string 2)
874 code (string-to-int (match-string 3) 16))
876 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%04X.png\"
879 chise-wiki-bitmap-glyphs-url
881 www-format-char-img-style)
884 (goto-char (point-min))
885 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-KS-\\([0-9]+\\);" nil t)
886 (setq code (string-to-int (match-string 2)))
888 (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/KS%06d.png\"
889 style=\"vertical-align:middle\">"
891 chise-wiki-bitmap-glyphs-url
893 www-format-char-img-style)
896 (goto-char (point-min))
897 (while (re-search-forward "&G\\([01]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
898 (setq plane (string-to-int (match-string 1))
899 code (string-to-int (match-string 2) 16))
901 (format "<img alt=\"GB%d-%04X\" src=\"%s/GB%d/%02d-%02d.gif\"
904 chise-wiki-bitmap-glyphs-url
907 (- (logand code 255) 32)
908 www-format-char-img-style)
911 (goto-char (point-min))
912 (while (re-search-forward "&\\(R-\\)?C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
913 (setq plane (string-to-int (match-string 2))
914 code (string-to-int (match-string 3) 16))
916 (format "<img alt=\"CNS%d-%04X\" src=\"%s/CNS%d/%04X.gif\"
919 chise-wiki-bitmap-glyphs-url
921 www-format-char-img-style)
924 (goto-char (point-min))
925 (while (re-search-forward "&\\(R-\\)?JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
926 (setq code (string-to-int (match-string 2) 16))
928 (format "<img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">"
932 (goto-char (point-min))
933 (while (re-search-forward "&\\(A-\\)?ZOB-\\([0-9]+\\);" nil t)
934 (setq code (string-to-int (match-string 2)))
936 (format "<img alt=\"ZOB-%04d\" src=\"%s/ZOB-1968/%04d.png\"
937 style=\"vertical-align:middle\">"
939 chise-wiki-bitmap-glyphs-url
941 www-format-char-img-style)
944 (goto-char (point-min))
945 (while (re-search-forward "&HNG\\([0-9]+\\)-\\([0-9][0-9][0-9][0-9]\\)\\([0-9]\\);" nil t)
946 (setq plane (match-string 1)
947 code (string-to-int (match-string 2))
948 subcode (string-to-int (match-string 3)))
952 (char-to-string (decode-char 'ascii (+ 96 subcode)))))
955 "<img alt=\"HNG%s-%04d%s\" src=\"%s/%s/%04d%s.png\"
956 style=\"vertical-align:middle; width: 48px; height: 48px\">"
958 chise-wiki-hng-bitmap-glyphs-url
960 www-format-char-img-style)
963 (goto-char (point-min))
964 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?AJ1-\\([0-9]+\\);" nil t)
965 (setq code (string-to-int (match-string 2)))
967 (format "<img alt=\"AJ1-%05d\" src=\"%s/IVD/AdobeJapan1/CID+%d.png\"
968 style=\"vertical-align:middle\">"
970 chise-wiki-bitmap-glyphs-url
972 www-format-char-img-style)
975 (goto-char (point-min))
976 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?MJ\\([0-9]+\\);" nil t)
977 (setq code (string-to-int (match-string 2)))
979 (format "<img alt=\"MJ%06d\" src=\"http://mojikiban.ipa.go.jp/search/MJ%06d\"
980 style=\"vertical-align:middle; width: 48px; height: 48px\">"
983 www-format-char-img-style)
986 (goto-char (point-min))
987 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?U-i\\([0-9]+\\)\\+\\([0-9A-F]+\\);" nil t)
988 (setq plane (string-to-int (match-string 2))
989 code (string-to-int (match-string 3) 16))
991 (format "<img alt=\"u%04x-itaiji-%03d\" src=\"http://glyphwiki.org/glyph/u%04x-itaiji-%03d.100px.png\"
992 style=\"vertical-align:middle; width: 48px; height: 48px\">"
997 www-format-char-img-style)
1000 (goto-char (point-min))
1001 (while (re-search-forward "&\\(G-\\|R-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
1002 (setq code (string-to-int (match-string 2)))
1004 (format "<img alt=\"GT-%05d\" src=\"%s?char=GT-%05d\"
1007 chise-wiki-glyph-cgi-url
1009 www-format-char-img-style)
1012 (goto-char (point-min))
1013 (while (re-search-forward "&\\(G-\\)?GT-K\\([0-9]+\\);" nil t)
1014 (setq code (string-to-int (match-string 2)))
1016 (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\"
1019 chise-wiki-glyph-cgi-url
1021 www-format-char-img-style)
1024 (goto-char (point-min))
1025 (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
1026 (setq code (string-to-int (match-string 1) 16))
1028 (format "<img alt=\"B-%04X\" src=\"%s?char=B-%04X\"
1031 chise-wiki-glyph-cgi-url
1033 www-format-char-img-style)
1036 (goto-char (point-min))
1037 (while (re-search-forward "&\\(G-\\|g2-\\|R-\\)?CDP-\\([0-9A-F]+\\);" nil t)
1038 (setq code (string-to-int (match-string 2) 16))
1040 (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
1043 chise-wiki-glyph-cgi-url
1045 www-format-char-img-style)
1048 (goto-char (point-min))
1049 (while (re-search-forward "&RUI6-\\([0-9A-F]+\\);" nil t)
1050 (setq code (string-to-int (match-string 1) 16))
1052 (format "<img alt=\"RUI6-%04X\" src=\"%s?char=RUI6-%04X\"
1053 style=\"vertical-align:middle\">"
1055 chise-wiki-glyph-cgi-url
1057 www-format-char-img-style)
1060 (goto-char (point-min))
1061 (while (re-search-forward "&hanaJU\\+\\([0-9A-F]+\\);" nil t)
1062 (setq code (string-to-int (match-string 1) 16))
1064 (format "<img alt=\"hanaJU+%04X\" src=\"%s?char=hana-JU+%04X\"
1065 style=\"vertical-align:middle\">"
1067 chise-wiki-glyph-cgi-url
1069 www-format-char-img-style)
1072 (goto-char (point-min))
1073 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\|R-\\)?\\(UU\\+\\|U-\\)\\([0-9A-F]+\\);" nil t)
1074 (setq code (string-to-int (match-string 3) 16))
1076 (format "<img alt=\"UU+%04X\" src=\"http://www.unicode.org/cgi-bin/refglyph?24-%04X\"
1077 style=\"vertical-align:middle\">"
1080 www-format-char-img-style)
1083 (goto-char (point-min))
1084 (while (re-search-forward "&MCS-\\([0-9A-F]+\\);" nil t)
1085 (setq code (string-to-int (match-string 1) 16))
1086 (setq start (match-beginning 0)
1088 (setq char (decode-char 'system-char-id code))
1090 ((and (setq variants
1091 (or (www-get-feature-value char '->subsumptive)
1092 (www-get-feature-value char '->denotational)))
1094 (while (and variants
1095 (setq ret (www-format-encode-string
1096 (char-to-string (car variants))))
1097 (string-match "&MCS-\\([0-9A-F]+\\);" ret))
1098 (setq variants (cdr variants)))
1100 (unless (string-match "&MCS-\\([0-9A-F]+\\);" ret)
1102 (delete-region start end)
1105 ((setq ret (or (www-get-feature-value char 'ideographic-combination)
1106 (www-get-feature-value char 'ideographic-structure)))
1111 (if (characterp (setq rret (find-char ch)))
1114 (www-format-encode-string
1115 (char-to-string ch) without-tags)
1116 (www-format-encode-string
1117 (format "%S" ch) without-tags)))
1121 (delete-region start end)
1125 ;; (goto-char (point-min))
1126 ;; (while (search-forward ">-" nil t)
1127 ;; (replace-match "&GT-" t 'literal))
1130 (defun www-html-display-text (text)
1134 (goto-char (point-min))
1135 (while (search-forward "<" nil t)
1136 (replace-match "<" nil t))
1137 (goto-char (point-min))
1138 (while (search-forward ">" nil t)
1139 (replace-match ">" nil t))
1140 (goto-char (point-min))
1141 (while (re-search-forward "\\[\\[\\([^]|[]+\\)|\\([^][]+\\)\\]\\]" nil t)
1143 (format "<a href=\"%s\">%s</a>"
1147 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
1148 (goto-char (point-min))
1149 (while (search-forward ">-" nil t)
1150 (replace-match "&GT-" nil t))
1153 (defun www-html-display-paragraph (text)
1155 (www-html-display-text text)
1162 (defvar coded-charset-GlyphWiki-id-alist
1163 '((=ucs "u" 4 x nil)
1164 (=adobe-japan1-0 "aj1-" 5 d nil)
1165 (=adobe-japan1-1 "aj1-" 5 d nil)
1166 (=adobe-japan1-2 "aj1-" 5 d nil)
1167 (=adobe-japan1-3 "aj1-" 5 d nil)
1168 (=adobe-japan1-4 "aj1-" 5 d nil)
1169 (=adobe-japan1-5 "aj1-" 5 d nil)
1170 (=adobe-japan1-6 "aj1-" 5 d nil)
1171 (==adobe-japan1-0 "aj1-" 5 d nil)
1172 (==adobe-japan1-1 "aj1-" 5 d nil)
1173 (==adobe-japan1-2 "aj1-" 5 d nil)
1174 (==adobe-japan1-3 "aj1-" 5 d nil)
1175 (==adobe-japan1-4 "aj1-" 5 d nil)
1176 (==adobe-japan1-5 "aj1-" 5 d nil)
1177 (==adobe-japan1-6 "aj1-" 5 d nil)
1178 (===adobe-japan1-0 "aj1-" 5 d nil)
1179 (===adobe-japan1-1 "aj1-" 5 d nil)
1180 (===adobe-japan1-2 "aj1-" 5 d nil)
1181 (===adobe-japan1-3 "aj1-" 5 d nil)
1182 (===adobe-japan1-4 "aj1-" 5 d nil)
1183 (===adobe-japan1-5 "aj1-" 5 d nil)
1184 (===adobe-japan1-6 "aj1-" 5 d nil)
1185 (=decomposition@cid)
1186 (=decomposition@hanyo-denshi)
1187 (=hanyo-denshi/ks "koseki-" 6 d nil)
1188 (=>>hanyo-denshi/ks "koseki-" 6 d nil)
1189 (=ucs@jis "u" 4 x nil)
1190 (==ucs@jis "u" 4 x nil)
1191 (===ucs@jis "u" 4 x nil)
1192 (=ucs@cns "u" 4 x "-t")
1193 (==ucs@cns "u" 4 x "-t")
1194 (=jis-x0212 "jsp-" 4 x nil)
1195 (=jis-x0213-1@2000 "jx1-2000-" 4 x nil)
1196 (=jis-x0213-1@2004 "jx1-2004-" 4 x nil)
1197 (=jis-x0213-2 "jx2-" 4 x nil)
1199 (=daikanwa "dkw-" 5 d nil)
1200 (==daikanwa "dkw-" 5 d nil)
1201 (===daikanwa "dkw-" 5 d nil)
1202 (=gt-k "gt-k" 5 d nil)
1203 (=jef-china3 "jc3-" 4 x nil)
1204 (=big5 "b-" 4 x nil)
1205 (=ucs@ks "u" 4 x "-k")
1206 (==ucs@ks "u" 4 x "-k")
1207 (===ucs@ks "u" 4 x "-k")
1208 (=ks-x1001 "k0-" 4 x nil)
1209 (=jis-x0208@1978/1pr "j78-" 4 x nil)
1210 (=jis-x0208@1978/-4pr "j78-" 4 x nil)
1211 (=jis-x0208@1978 "j78-" 4 x nil)
1212 (=>>>jis-x0208@1978 "j78-" 4 x nil)
1213 (=>>jis-x0208@1978 "j78-" 4 x nil)
1214 (=+>jis-x0208@1978 "j78-" 4 x nil)
1215 (=ucs@JP "u" 4 x nil)
1216 (=ucs@gb "u" 4 x "-g")
1217 (=ucs@iso "u" 4 x "-u")
1218 (=ucs@unicode "u" 4 x "-us")
1219 (=big5-cdp "cdp-" 4 x nil)
1220 (=>>big5-cdp "cdp-" 4 x nil)
1221 (=cns11643-1 "c1-" 4 x nil)
1222 (=cns11643-2 "c2-" 4 x nil)
1223 (=cns11643-3 "c3-" 4 x nil)
1224 (=cns11643-4 "c4-" 4 x nil)
1225 (=cns11643-5 "c5-" 4 x nil)
1226 (=cns11643-6 "c6-" 4 x nil)
1227 (=cns11643-7 "c7-" 4 x nil)
1228 (=jis-x0208 "j90-" 4 x nil)
1229 (=>>>jis-x0208 "j90-" 4 x nil)
1230 (=>>jis-x0208 "j90-" 4 x nil)
1231 (=+>jis-x0208 "j90-" 4 x nil)
1232 (=jis-x0208@1990 "j90-" 4 x nil)
1233 (=>>>jis-x0208@1990 "j90-" 4 x nil)
1234 (=>>jis-x0208@1990 "j90-" 4 x nil)
1235 (=+>jis-x0208@1990 "j90-" 4 x nil)
1236 (=jis-x0208@1983 "j83-" 4 x nil)
1237 (=>>>jis-x0208@1983 "j83-" 4 x nil)
1238 (=>>jis-x0208@1983 "j83-" 4 x nil)
1239 (=+>jis-x0208@1983 "j83-" 4 x nil)
1240 (=cbeta "cb" 5 d nil)
1241 (=>>daikanwa "dkw-" 5 d nil)
1242 (=ucs-var-001 "u" 4 x "-var-001")
1243 (=ucs-var-002 "u" 4 x "-var-002")
1244 (=ucs-var-003 "u" 4 x "-var-003")
1245 (=ucs-itaiji-002 "u" 4 x "-itaiji-002")
1246 (=ucs-itaiji-084 "u" 4 x "-itaiji-084")
1247 (=big5-cdp-var-3 "cdp-" 4 x "-var-3")
1248 (=big5-cdp-var-5 "cdp-" 4 x "-var-5")
1251 (defun char-GlyphWiki-id (char)
1252 (let ((rest coded-charset-GlyphWiki-id-alist)
1255 (setq spec (pop rest))
1256 (null (setq ret (char-feature char (car spec))))))
1260 (mapconcat #'char-GlyphWiki-id ret "-"))
1261 (and (memq (car spec) '(=ucs@unicode '=ucs@iso))
1263 ((and (or (encode-char char '=jis-x0208@1990)
1264 (encode-char char '=jis-x0212)
1265 (encode-char char '=jis-x0213-1)
1266 (encode-char char '=jis-x0213-2))
1267 (setq code (encode-char char '=ucs@jis)))
1268 (format "u%04x" code)
1270 ((and (or (encode-char char '=gb2312)
1271 (encode-char char '=gb12345))
1272 (setq code (encode-char char '=ucs@gb)))
1273 (format "u%04x-g" code)
1275 ((and (or (encode-char char '=cns11643-1)
1276 (encode-char char '=cns11643-2)
1277 (encode-char char '=cns11643-3)
1278 (encode-char char '=cns11643-4)
1279 (encode-char char '=cns11643-5)
1280 (encode-char char '=cns11643-6)
1281 (encode-char char '=cns11643-7))
1282 (setq code (encode-char char '=ucs@cns)))
1283 (format "u%04x-t" code)
1285 ((and (encode-char char '=ks-x1001)
1286 (setq code (encode-char char '=ucs@ks)))
1287 (format "u%04x-k" code)
1289 (format (format "%s%%0%d%s%s"
1293 (or (nth 4 spec) ""))
1300 (provide 'cwiki-common)
1302 ;;; cwiki-common.el ends here