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
93 (defun decode-uri-string (string &optional coding-system)
94 (if (> (length string) 0)
98 (mapconcat (lambda (char)
101 (char-to-string char)))
103 (while (string-match "%\\([0-9A-F][0-9A-F]\\)" string i)
104 (setq dest (concat dest
105 (substring string i (match-beginning 0))
108 (string-to-int (match-string 1 string) 16))))
110 (decode-coding-string
111 (concat dest (substring string i))
114 (defun www-feature-type (feature-name)
115 (or (char-feature-property feature-name 'type)
116 (let ((str (symbol-name feature-name)))
118 ((string-match "\\*note\\(@[^*]+\\)?$" str)
120 ((string-match "\\*sources\\(@[^*]+\\)?$" str)
122 ((string-match "\\*" str)
124 ((string-match "^\\(->\\|<-\\)" str)
126 ((string-match "^ideographic-structure\\(@\\|$\\)" str)
130 (defun www-feature-format (feature-name)
131 (or (char-feature-property feature-name 'presentation-format)
132 (char-feature-property feature-name 'format)
134 (setq fn feature-name)
135 (while (and (setq parent (char-feature-name-parent fn))
137 (char-feature-property
141 '((name) " : " (value))))
143 (defun www-feature-value-format (feature-name)
144 (or (char-feature-property feature-name 'value-presentation-format)
145 (char-feature-property feature-name 'value-format)
147 (setq fn feature-name)
148 (while (and (setq parent (char-feature-name-parent fn))
150 (or (char-feature-property
151 parent 'value-presentation-format)
152 (char-feature-property
153 parent 'value-format)))))
156 (let ((type (www-feature-type feature-name)))
157 (cond ((eq type 'relation)
159 ((eq type 'structure)
160 'space-separated-ids)
164 (if (find-charset feature-name)
165 (if (and (= (charset-dimension feature-name) 2)
166 (= (charset-chars feature-name) 94))
168 " (" (decimal) ") <" (ku-ten) "> " (prev-char) (next-char))
169 '("0x" (HEX) " (" (decimal) ") " (prev-char) (next-char))))
172 (defun char-feature-name-at-domain (feature-name domain)
174 (let ((name (symbol-name feature-name)))
176 ((string-match "@[^*]+$" name)
177 (intern (format "%s/%s" name domain))
180 (intern (format "%s@%s" name domain))
184 (defun char-feature-name-parent (feature-name)
185 (let ((name (symbol-name feature-name)))
186 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
187 (intern (substring name 0 (car (last (match-data) 2)))))))
189 (defun char-feature-name-domain (feature-name)
190 (let ((name (symbol-name feature-name)))
191 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
192 (intern (substring name (1+ (match-beginning 0)))))))
194 (defun char-feature-name-sans-versions (feature)
195 (let ((feature-name (symbol-name feature)))
196 (if (string-match "[@/]\\$rev=latest$" feature-name)
197 (intern (substring feature-name 0 (match-beginning 0)))
200 (defun est-object-genre (object)
201 (if (characterp object)
203 (concord-object-genre object)))
205 (defun www-get-feature-value (object feature)
206 (let ((latest-feature (char-feature-name-at-domain feature '$rev=latest)))
209 (mount-char-attribute-table latest-feature)
210 (or (char-feature object latest-feature)
211 (char-feature object feature))
214 (or (condition-case nil
215 (concord-object-get object latest-feature)
218 (concord-object-get object feature)
222 (defun get-previous-code-point (ccs code)
223 (let ((chars (charset-chars ccs))
224 (dim (charset-dimension ccs))
226 mask byte-min byte-max
249 (setq bytes (make-vector dim 0))
251 (aset bytes i (logand (lsh code (* i -8)) mask))
254 (while (and (< i dim)
256 (aset bytes i (1- (aref bytes i)))
257 (< (aref bytes i) byte-min)))
258 (aset bytes i byte-max)
261 (setq dest (aref bytes 0)
264 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
268 (defun get-next-code-point (ccs code)
269 (let ((chars (charset-chars ccs))
270 (dim (charset-dimension ccs))
272 mask byte-min byte-max
295 (setq bytes (make-vector dim 0))
297 (aset bytes i (logand (lsh code (* i -8)) mask))
300 (while (and (< i dim)
302 (aset bytes i (1+ (aref bytes i)))
303 (> (aref bytes i) byte-max)))
304 (aset bytes i byte-min)
307 (setq dest (aref bytes 0)
310 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
314 (defun find-previous-defined-code-point (ccs code)
315 (let ((i (get-previous-code-point ccs code))
318 ((eq ccs '=jis-x0208)
319 (setq ccs '=jis-x0208@1990))
320 ((eq ccs '=jis-x0213-1)
321 (setq ccs '=jis-x0213-1@2004)))
324 (null (setq char (decode-char ccs i
325 (unless (eq ccs '=ucs)
327 (setq i (get-previous-code-point ccs i)))
330 (defun find-next-defined-code-point (ccs code)
331 (let ((i (get-next-code-point ccs code))
333 (setq max (+ code 1000))
335 ((eq ccs '=jis-x0208)
336 (setq ccs '=jis-x0208@1990))
337 ((eq ccs '=jis-x0213-1)
338 (setq ccs '=jis-x0213-1@2004)))
341 (null (setq char (decode-char ccs i
342 (unless (eq ccs '=ucs)
344 (setq i (get-next-code-point ccs i)))
348 ;;; @ URI representation
351 (defun est-uri-decode-feature-name-body (uri-feature)
352 (let ((len (length uri-feature))
359 (if (eq (aref uri-feature i) ?\.)
360 (if (and (< (+ i 2) len)
361 (eq (aref uri-feature (+ i 2)) ?\.))
364 ((eq (setq ch (aref uri-feature (1+ i))) ?\.)
369 (substring uri-feature i (+ i 3))
375 (char-to-string (aref uri-feature i))
379 (defun est-uri-encode-feature-name-body (feature)
380 (mapconcat (lambda (c)
385 (t (char-to-string c))))
388 (defun www-uri-decode-feature-name (uri-feature)
390 (setq uri-feature (decode-uri-string uri-feature 'utf-8-mcs-er))
392 ((string-match "^from\\." uri-feature)
393 (intern (format "<-%s"
394 (est-uri-decode-feature-name-body
395 (substring uri-feature (match-end 0)))))
397 ((string-match "^to\\." uri-feature)
398 (intern (format "->%s"
399 (est-uri-decode-feature-name-body
400 (substring uri-feature (match-end 0)))))
402 ((string-match "^rep\\." uri-feature)
403 (intern (format "=%s"
404 (est-uri-decode-feature-name-body
405 (substring uri-feature (match-end 0)))))
407 ((string-match "^rep[2i]\\." uri-feature)
408 (intern (format "===%s"
409 (est-uri-decode-feature-name-body
410 (substring uri-feature (match-end 0)))))
412 ((string-match "^g\\." uri-feature)
413 (intern (format "=>>%s"
414 (est-uri-decode-feature-name-body
415 (substring uri-feature (match-end 0)))))
417 ((string-match "^g[i2]\\." uri-feature)
418 (intern (format "==%s"
419 (est-uri-decode-feature-name-body
420 (substring uri-feature (match-end 0)))))
422 ((string-match "^gi\\([0-9]+\\)\\." uri-feature)
423 (intern (format "=>>%s%s"
424 (make-string (string-to-int
425 (match-string 1 uri-feature))
427 (est-uri-decode-feature-name-body
428 (substring uri-feature (match-end 0)))))
430 ((string-match "^o\\." uri-feature)
431 (intern (format "=+>%s"
432 (est-uri-decode-feature-name-body
433 (substring uri-feature (match-end 0)))))
435 ((string-match "^a\\." uri-feature)
436 (intern (format "=>%s"
437 (est-uri-decode-feature-name-body
438 (substring uri-feature (match-end 0)))))
440 ((string-match "^a\\([0-9]+\\)\\." uri-feature)
441 (intern (format "%s>%s"
442 (make-string (string-to-int
443 (match-string 1 uri-feature))
445 (est-uri-decode-feature-name-body
446 (substring uri-feature (match-end 0)))))
448 ((and (setq uri-feature (est-uri-decode-feature-name-body uri-feature))
449 (setq feature (intern (format "=>%s" uri-feature)))
450 (find-charset feature))
452 ((and (setq feature (intern (format "=>>%s" uri-feature)))
453 (find-charset feature))
455 ((and (setq feature (intern (format "=>>>%s" uri-feature)))
456 (find-charset feature))
458 ((and (setq feature (intern (format "=%s" uri-feature)))
459 (find-charset feature))
461 (t (intern uri-feature)))))
463 (defun www-uri-encode-feature-name (feature-name)
464 (setq feature-name (symbol-name feature-name))
466 ((string-match "^=\\+>\\([^=>]+\\)" feature-name)
468 (est-uri-encode-feature-name-body
469 (substring feature-name (match-beginning 1))))
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 (length (match-string 1 feature-name))
499 (est-uri-encode-feature-name-body
500 (substring feature-name (match-end 1))))
502 ((string-match "^=>\\([^=>]+\\)" feature-name)
504 (est-uri-encode-feature-name-body
505 (substring feature-name (match-beginning 1))))
507 ((string-match "^\\(=+\\)>" feature-name)
509 (length (match-string 1 feature-name))
510 (est-uri-encode-feature-name-body
511 (substring feature-name (match-end 0))))
513 ((string-match "^->" 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 (t (est-uri-encode-feature-name-body feature-name))))
525 (defun www-uri-make-feature-name-url (uri-genre uri-feature-name uri-object)
526 (if est-hide-cgi-mode
527 (format "../feature/%s&%s/%s"
528 uri-feature-name uri-genre uri-object)
529 (format "%s?feature=%s&%s=%s"
530 chise-wiki-view-url uri-feature-name uri-genre uri-object)))
532 (defun www-uri-decode-object (genre char-rep)
535 ((string-match (if est-hide-cgi-mode
536 "\\(%3D\\|=\\|%3A\\|:\\)"
537 "\\(%3A\\|:\\)") char-rep)
538 (setq ccs (substring char-rep 0 (match-beginning 0))
539 cpos (substring char-rep (match-end 0)))
540 (setq ccs (www-uri-decode-feature-name ccs))
541 (setq cpos (est-uri-decode-feature-name-body cpos))
543 ((string-match "^0x" cpos)
545 (string-to-number (substring cpos (match-end 0)) 16))
548 (setq cpos (car (read-from-string
550 cpos file-name-coding-system))))
552 (if (and (eq genre 'character)
554 (decode-char ccs cpos)
555 (concord-decode-object ccs cpos genre))
558 (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er))
560 ((eq genre 'character)
561 (when (= (length char-rep) 1)
565 (concord-decode-object
566 '=id (www-uri-decode-feature-name char-rep) 'feature)
569 (concord-decode-object
570 '=id (car (read-from-string char-rep)) genre)
573 (defun www-uri-encode-object (object)
574 (if (characterp object)
575 (if (encode-char object '=ucs)
578 (format "%%%02X" byte))
579 (encode-coding-string (char-to-string object) 'utf-8-mcs-er)
581 (let ((ccs-list est-coded-charset-priority-list)
584 (setq ccs (pop ccs-list))
585 (not (setq ret (encode-char object ccs 'defined-only)))))
587 (format (if est-hide-cgi-mode
590 (www-uri-encode-feature-name ccs)
592 ((and (setq ccs (car (split-char object)))
593 (setq ret (encode-char object ccs)))
594 (format (if est-hide-cgi-mode
597 (www-uri-encode-feature-name ccs)
600 (format (if est-hide-cgi-mode
601 "system-char-id=0x%X"
602 "system-char-id:0x%X")
603 (encode-char object 'system-char-id))
605 (format (if est-hide-cgi-mode
608 (est-uri-encode-feature-name-body
609 (format "%s" (concord-object-id object))))))
611 (defun est-format-object (object &optional readable)
612 (if (characterp object)
613 (char-to-string object)
614 (let ((ret (or (if readable
615 (or (concord-object-get object 'name)
616 (concord-object-get object '=name)
617 (concord-object-get object 'title)))
618 (concord-object-id object))))
621 (defun www-uri-make-object-url (object &optional uri-object)
622 (if est-hide-cgi-mode
625 (est-object-genre object)
627 (www-uri-encode-object object)))
630 (est-object-genre object)
632 (www-uri-encode-object object)))))
635 ;;; @ Feature name presentation
638 (defun www-format-feature-name-default (feature-name)
642 (symbol-name feature-name)
646 (defun www-format-feature-name-as-metadata (feature-name &optional lang)
647 (let ((str (symbol-name feature-name))
650 ((string-match "\\*[^*]+$" str)
651 (setq base (substring str 0 (match-beginning 0))
652 meta (substring str (match-beginning 0)))
653 (concat (www-format-feature-name* (intern base) lang)
656 (www-format-feature-name-default feature-name)
659 (defun www-format-feature-name-as-rel-to (feature-name)
660 (concat "\u2192" (substring (symbol-name feature-name) 2)))
662 (defun www-format-feature-name-as-rel-from (feature-name)
663 (concat "\u2190" (substring (symbol-name feature-name) 2)))
665 (defun www-format-feature-name-as-CCS (feature-name)
668 (symbol-name feature-name)
670 (dest (upcase (pop rest))))
671 (when (string-match "^=+>*" dest)
672 (setq dest (concat (substring dest 0 (match-end 0))
674 (substring dest (match-end 0)))))
678 (setq dest (concat dest " " (upcase (pop rest)))))
679 (if (string-match "^[0-9]+$" (car rest))
680 (concat dest "-" (car rest))
681 (concat dest " " (upcase (car rest))))
685 (defun www-format-feature-name* (feature-name &optional lang)
686 (let (name fn parent ret)
689 (char-feature-property
691 (intern (format "name@%s" lang))))
692 (char-feature-property
693 feature-name 'name)))
694 ((and (setq name (symbol-name feature-name))
695 (string-match "\\*" name))
696 (www-format-feature-name-as-metadata feature-name lang))
698 (setq fn feature-name)
699 (while (and (setq parent (char-feature-name-parent fn))
702 (char-feature-property
704 (intern (format "name@%s" lang))))
705 (char-feature-property
710 (concat ret (substring (symbol-name feature-name)
711 (length (symbol-name parent)))))
712 ((find-charset feature-name)
713 (www-format-feature-name-as-CCS feature-name))
714 ((string-match "^\\(->\\)" name)
715 (www-format-feature-name-as-rel-to feature-name))
716 ((string-match "^\\(<-\\)" name)
717 (www-format-feature-name-as-rel-from feature-name))
719 (www-format-feature-name-default feature-name)
723 (defun www-format-feature-name (feature-name &optional lang)
724 (www-format-encode-string
725 (www-format-feature-name* feature-name lang)))
731 (defvar www-format-char-img-style "vertical-align:bottom;")
733 (defun www-format-encode-string (string &optional without-tags as-body)
736 (let (plane code subcode start end char variants ret rret)
738 (goto-char (point-min))
739 (while (search-forward "&" nil t)
740 (replace-match "&" nil t)))
741 (goto-char (point-min))
742 (while (search-forward "<" nil t)
743 (replace-match "<" nil t))
744 (goto-char (point-min))
745 (while (search-forward ">" nil t)
746 (replace-match ">" nil t))
748 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
749 (let ((coded-charset-entity-reference-alist
752 '(=hanyo-denshi/ja "HD-JA-" 4 X)
753 '(=hanyo-denshi/jb "HD-JB-" 4 X)
754 '(=hanyo-denshi/jc "HD-JC-" 4 X)
755 '(=hanyo-denshi/jd "HD-JD-" 4 X)
756 '(=hanyo-denshi/ft "HD-FT-" 4 X)
757 '(=hanyo-denshi/ia "HD-IA-" 4 X)
758 '(=hanyo-denshi/ib "HD-IB-" 4 X)
759 '(=hanyo-denshi/hg "HD-HG-" 4 X)
760 '(=hanyo-denshi/ip "HD-IP-" 4 X)
761 '(=hanyo-denshi/jt "HD-JT-" 4 X)
762 '(=hanyo-denshi/ks "HD-KS-" 6 d)
763 '(=>>hanyo-denshi/ja "G-HD-JA-" 4 X)
764 '(=>>hanyo-denshi/jb "G-HD-JB-" 4 X)
765 '(=>>hanyo-denshi/jc "G-HD-JC-" 4 X)
766 '(=>>hanyo-denshi/jd "G-HD-JD-" 4 X)
767 '(=>>hanyo-denshi/ft "G-HD-FT-" 4 X)
768 '(=>>hanyo-denshi/ia "G-HD-IA-" 4 X)
769 '(=>>hanyo-denshi/ib "G-HD-IB-" 4 X)
770 '(=>>hanyo-denshi/hg "G-HD-HG-" 4 X)
771 '(=>>hanyo-denshi/ip "G-HD-IP-" 4 X)
772 '(=>>hanyo-denshi/jt "G-HD-JT-" 4 X)
773 '(=>>hanyo-denshi/ks "G-HD-KS-" 6 d)
774 '(==hanyo-denshi/ja "g2-HD-JA-" 4 X)
775 '(==hanyo-denshi/jb "g2-HD-JB-" 4 X)
776 '(==hanyo-denshi/jc "g2-HD-JC-" 4 X)
777 '(==hanyo-denshi/jd "g2-HD-JD-" 4 X)
778 '(==hanyo-denshi/ft "g2-HD-FT-" 4 X)
779 '(==hanyo-denshi/ia "g2-HD-IA-" 4 X)
780 '(==hanyo-denshi/ib "g2-HD-IB-" 4 X)
781 '(==hanyo-denshi/hg "g2-HD-HG-" 4 X)
782 '(==hanyo-denshi/ip "g2-HD-IP-" 4 X)
783 '(==hanyo-denshi/jt "g2-HD-JT-" 4 X)
784 '(==hanyo-denshi/ks "g2-HD-KS-" 6 d)
785 '(=cns11643-1 "C1-" 4 X)
786 '(=cns11643-2 "C2-" 4 X)
787 '(=cns11643-3 "C3-" 4 X)
788 '(=cns11643-4 "C4-" 4 X)
789 '(=cns11643-5 "C5-" 4 X)
790 '(=cns11643-6 "C6-" 4 X)
791 '(=cns11643-7 "C7-" 4 X)
792 '(=adobe-japan1-6 "AJ1-" 5 d)
793 '(=big5-cdp "CDP-" 4 X)
795 '(=gb12345 "G1-" 4 X)
796 '(=jis-x0208@1990 "J90-" 4 X)
797 '(=jis-x0212 "JSP-" 4 X)
799 '(=jis-x0208@1997 "J97-" 4 X)
800 '(=jis-x0208@1978 "J78-" 4 X)
801 '(=jis-x0208@1983 "J83-" 4 X)
802 '(=ruimoku-v6 "RUI6-" 4 X)
803 '(=zinbun-oracle "ZOB-" 4 d)
804 '(=jef-china3 "JC3-" 4 X)
805 '(=ucs@unicode "UU+" 4 X)
806 '(=ucs@JP/hanazono "hanaJU+" 4 X)
807 '(=daikanwa "M-" 5 d)
808 '(==cns11643-1 "R-C1-" 4 X)
809 '(==cns11643-2 "R-C2-" 4 X)
810 '(==cns11643-3 "R-C3-" 4 X)
811 '(==cns11643-4 "R-C4-" 4 X)
812 '(==cns11643-5 "R-C5-" 4 X)
813 '(==cns11643-6 "R-C6-" 4 X)
814 '(==cns11643-7 "R-C7-" 4 X)
815 coded-charset-entity-reference-alist)))
816 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
818 (goto-char (point-min))
819 (while (re-search-forward "&CB\\([0-9]+\\);" nil t)
820 (setq code (string-to-int (match-string 1)))
822 (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
825 chise-wiki-bitmap-glyphs-url
827 www-format-char-img-style)
830 (goto-char (point-min))
831 (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)
832 (setq plane (match-string 2)
833 code (string-to-int (match-string 3) 16))
835 (format "<img alt=\"J%s-%04X\" src=\"%s/JIS-%s/%02d-%02d.gif\"
838 chise-wiki-bitmap-glyphs-url
841 (- (logand code 255) 32)
842 www-format-char-img-style)
845 (goto-char (point-min))
846 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?J0-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
847 (setq code (string-to-int (match-string 2) 16))
849 (format "<img alt=\"J0-%04X\" src=\"%s/JIS-90/%02d-%02d.gif\"
852 chise-wiki-bitmap-glyphs-url
854 (- (logand code 255) 32)
855 www-format-char-img-style)
858 (goto-char (point-min))
859 (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)
860 (setq plane (match-string 2)
861 code (string-to-int (match-string 3) 16))
863 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%02d%02d.png\"
866 chise-wiki-bitmap-glyphs-url
869 (- (logand code 255) 32)
870 www-format-char-img-style)
873 (goto-char (point-min))
874 (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)
875 (setq plane (match-string 2)
876 code (string-to-int (match-string 3) 16))
878 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%04X.png\"
881 chise-wiki-bitmap-glyphs-url
883 www-format-char-img-style)
886 (goto-char (point-min))
887 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-KS-\\([0-9]+\\);" nil t)
888 (setq code (string-to-int (match-string 2)))
890 (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/KS%06d.png\"
891 style=\"vertical-align:middle\">"
893 chise-wiki-bitmap-glyphs-url
895 www-format-char-img-style)
898 (goto-char (point-min))
899 (while (re-search-forward "&G\\([01]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
900 (setq plane (string-to-int (match-string 1))
901 code (string-to-int (match-string 2) 16))
903 (format "<img alt=\"GB%d-%04X\" src=\"%s/GB%d/%02d-%02d.gif\"
906 chise-wiki-bitmap-glyphs-url
909 (- (logand code 255) 32)
910 www-format-char-img-style)
913 (goto-char (point-min))
914 (while (re-search-forward "&\\(R-\\)?C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
915 (setq plane (string-to-int (match-string 2))
916 code (string-to-int (match-string 3) 16))
918 (format "<img alt=\"CNS%d-%04X\" src=\"%s/CNS%d/%04X.gif\"
921 chise-wiki-bitmap-glyphs-url
923 www-format-char-img-style)
926 (goto-char (point-min))
927 (while (re-search-forward "&\\(R-\\)?JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
928 (setq code (string-to-int (match-string 2) 16))
930 (format "<img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">"
934 (goto-char (point-min))
935 (while (re-search-forward "&\\(A-\\)?ZOB-\\([0-9]+\\);" nil t)
936 (setq code (string-to-int (match-string 2)))
938 (format "<img alt=\"ZOB-%04d\" src=\"%s/ZOB-1968/%04d.png\"
939 style=\"vertical-align:middle\">"
941 chise-wiki-bitmap-glyphs-url
943 www-format-char-img-style)
946 (goto-char (point-min))
947 (while (re-search-forward "&HNG\\([0-9]+\\)-\\([0-9][0-9][0-9][0-9]\\)\\([0-9]\\);" nil t)
948 (setq plane (match-string 1)
949 code (string-to-int (match-string 2))
950 subcode (string-to-int (match-string 3)))
954 (char-to-string (decode-char 'ascii (+ 96 subcode)))))
957 "<img alt=\"HNG%s-%04d%s\" src=\"%s/%s/%04d%s.png\"
958 style=\"vertical-align:middle; width: 48px; height: 48px\">"
960 chise-wiki-hng-bitmap-glyphs-url
962 www-format-char-img-style)
965 (goto-char (point-min))
966 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?AJ1-\\([0-9]+\\);" nil t)
967 (setq code (string-to-int (match-string 2)))
969 (format "<img alt=\"AJ1-%05d\" src=\"%s/IVD/AdobeJapan1/CID+%d.png\"
970 style=\"vertical-align:middle\">"
972 chise-wiki-bitmap-glyphs-url
974 www-format-char-img-style)
977 (goto-char (point-min))
978 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?MJ\\([0-9]+\\);" nil t)
979 (setq code (string-to-int (match-string 2)))
981 (format "<img alt=\"MJ%06d\" src=\"http://mojikiban.ipa.go.jp/search/MJ%06d\"
982 style=\"vertical-align:middle; width: 48px; height: 48px\">"
985 www-format-char-img-style)
988 (goto-char (point-min))
989 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?IU-\\([0-9A-F]+\\);" nil t)
990 (setq code (string-to-int (match-string 2) 16))
992 (format "<img alt=\"u%04x\" src=\"http://glyphwiki.org/glyph/u%04x.100px.png\"
993 style=\"vertical-align:middle; width: 48px; height: 48px\">"
996 www-format-char-img-style)
999 (goto-char (point-min))
1000 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?U-i\\([0-9]+\\)\\+\\([0-9A-F]+\\);" nil t)
1001 (setq plane (string-to-int (match-string 2))
1002 code (string-to-int (match-string 3) 16))
1004 (format "<img alt=\"u%04x-itaiji-%03d\" src=\"http://glyphwiki.org/glyph/u%04x-itaiji-%03d.100px.png\"
1005 style=\"vertical-align:middle; width: 48px; height: 48px\">"
1010 www-format-char-img-style)
1013 (goto-char (point-min))
1014 (while (re-search-forward "&\\(G-\\|R-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
1015 (setq code (string-to-int (match-string 2)))
1017 (format "<img alt=\"GT-%05d\" src=\"%s?char=GT-%05d\"
1020 chise-wiki-glyph-cgi-url
1022 www-format-char-img-style)
1025 (goto-char (point-min))
1026 (while (re-search-forward "&\\(G-\\)?GT-K\\([0-9]+\\);" nil t)
1027 (setq code (string-to-int (match-string 2)))
1029 (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\"
1032 chise-wiki-glyph-cgi-url
1034 www-format-char-img-style)
1037 (goto-char (point-min))
1038 (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
1039 (setq code (string-to-int (match-string 1) 16))
1041 (format "<img alt=\"B-%04X\" src=\"%s?char=B-%04X\"
1044 chise-wiki-glyph-cgi-url
1046 www-format-char-img-style)
1049 (goto-char (point-min))
1050 (while (re-search-forward "&\\(G-\\|g2-\\|R-\\)?CDP-\\([0-9A-F]+\\);" nil t)
1051 (setq code (string-to-int (match-string 2) 16))
1053 (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
1056 chise-wiki-glyph-cgi-url
1058 www-format-char-img-style)
1061 (goto-char (point-min))
1062 (while (re-search-forward "&RUI6-\\([0-9A-F]+\\);" nil t)
1063 (setq code (string-to-int (match-string 1) 16))
1065 (format "<img alt=\"RUI6-%04X\" src=\"%s?char=RUI6-%04X\"
1066 style=\"vertical-align:middle\">"
1068 chise-wiki-glyph-cgi-url
1070 www-format-char-img-style)
1073 (goto-char (point-min))
1074 (while (re-search-forward "&hanaJU\\+\\([0-9A-F]+\\);" nil t)
1075 (setq code (string-to-int (match-string 1) 16))
1077 (format "<img alt=\"hanaJU+%04X\" src=\"%s?char=hana-JU+%04X\"
1078 style=\"vertical-align:middle\">"
1080 chise-wiki-glyph-cgi-url
1082 www-format-char-img-style)
1085 (goto-char (point-min))
1086 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\|R-\\)?\\(UU\\+\\|U-\\)\\([0-9A-F]+\\);" nil t)
1087 (setq code (string-to-int (match-string 3) 16))
1089 (format "<img alt=\"UU+%04X\" src=\"http://www.unicode.org/cgi-bin/refglyph?24-%04X\"
1090 style=\"vertical-align:middle\">"
1093 www-format-char-img-style)
1096 (goto-char (point-min))
1097 (while (re-search-forward "&MCS-\\([0-9A-F]+\\);" nil t)
1098 (setq code (string-to-int (match-string 1) 16))
1099 (setq start (match-beginning 0)
1101 (setq char (decode-char 'system-char-id code))
1103 ((and (setq variants
1104 (or (www-get-feature-value char '->subsumptive)
1105 (www-get-feature-value char '->denotational)))
1107 (while (and variants
1108 (setq ret (www-format-encode-string
1109 (char-to-string (car variants))))
1110 (string-match "&MCS-\\([0-9A-F]+\\);" ret))
1111 (setq variants (cdr variants)))
1113 (unless (string-match "&MCS-\\([0-9A-F]+\\);" ret)
1115 (delete-region start end)
1118 ((setq ret (or (www-get-feature-value char 'ideographic-combination)
1119 (www-get-feature-value char 'ideographic-structure)))
1124 (if (characterp (setq rret (find-char ch)))
1127 (www-format-encode-string
1128 (char-to-string ch) without-tags)
1129 (www-format-encode-string
1130 (format "%S" ch) without-tags)))
1134 (delete-region start end)
1138 ;; (goto-char (point-min))
1139 ;; (while (search-forward ">-" nil t)
1140 ;; (replace-match "&GT-" t 'literal))
1143 (defun www-html-display-text (text)
1147 (goto-char (point-min))
1148 (while (search-forward "<" nil t)
1149 (replace-match "<" nil t))
1150 (goto-char (point-min))
1151 (while (search-forward ">" nil t)
1152 (replace-match ">" nil t))
1153 (goto-char (point-min))
1154 (while (re-search-forward "\\[\\[\\([^]|[]+\\)|\\([^][]+\\)\\]\\]" nil t)
1156 (format "<a href=\"%s\">%s</a>"
1160 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
1161 (goto-char (point-min))
1162 (while (search-forward ">-" nil t)
1163 (replace-match "&GT-" nil t))
1166 (defun www-html-display-paragraph (text)
1168 (www-html-display-text text)
1175 (defvar coded-charset-GlyphWiki-id-alist
1176 '((=ucs-var-001 "u" 4 x "-var-001")
1177 (=ucs-var-002 "u" 4 x "-var-002")
1178 (=ucs-var-003 "u" 4 x "-var-003")
1179 (=ucs-itaiji-001 "u" 4 x "-itaiji-001")
1180 (=ucs-itaiji-002 "u" 4 x "-itaiji-002")
1181 (=ucs-itaiji-084 "u" 4 x "-itaiji-084")
1183 (=adobe-japan1-0 "aj1-" 5 d nil)
1184 (=adobe-japan1-1 "aj1-" 5 d nil)
1185 (=adobe-japan1-2 "aj1-" 5 d nil)
1186 (=adobe-japan1-3 "aj1-" 5 d nil)
1187 (=adobe-japan1-4 "aj1-" 5 d nil)
1188 (=adobe-japan1-5 "aj1-" 5 d nil)
1189 (=adobe-japan1-6 "aj1-" 5 d nil)
1190 (==adobe-japan1-0 "aj1-" 5 d nil)
1191 (==adobe-japan1-1 "aj1-" 5 d nil)
1192 (==adobe-japan1-2 "aj1-" 5 d nil)
1193 (==adobe-japan1-3 "aj1-" 5 d nil)
1194 (==adobe-japan1-4 "aj1-" 5 d nil)
1195 (==adobe-japan1-5 "aj1-" 5 d nil)
1196 (==adobe-japan1-6 "aj1-" 5 d nil)
1197 (===adobe-japan1-0 "aj1-" 5 d nil)
1198 (===adobe-japan1-1 "aj1-" 5 d nil)
1199 (===adobe-japan1-2 "aj1-" 5 d nil)
1200 (===adobe-japan1-3 "aj1-" 5 d nil)
1201 (===adobe-japan1-4 "aj1-" 5 d nil)
1202 (===adobe-japan1-5 "aj1-" 5 d nil)
1203 (===adobe-japan1-6 "aj1-" 5 d nil)
1204 (=decomposition@cid)
1205 (=decomposition@hanyo-denshi)
1206 (=hanyo-denshi/ks "koseki-" 6 d nil)
1207 (=>>hanyo-denshi/ks "koseki-" 6 d nil)
1208 (=ucs@jis "u" 4 x nil)
1209 (==ucs@jis "u" 4 x nil)
1210 (==ucs@iso "u" 4 x nil)
1211 (===ucs@jis "u" 4 x nil)
1212 (=ucs@cns "u" 4 x "-t")
1213 (==ucs@cns "u" 4 x "-t")
1214 (=jis-x0212 "jsp-" 4 x nil)
1215 (=jis-x0213-1@2000 "jx1-2000-" 4 x nil)
1216 (=jis-x0213-1@2004 "jx1-2004-" 4 x nil)
1217 (=jis-x0213-2 "jx2-" 4 x nil)
1219 (=daikanwa "dkw-" 5 d nil)
1220 (==daikanwa "dkw-" 5 d nil)
1221 (===daikanwa "dkw-" 5 d nil)
1222 (=gt-k "gt-k" 5 d nil)
1223 (=jef-china3 "jc3-" 4 x nil)
1224 (=big5 "b-" 4 x nil)
1225 (=ucs@ks "u" 4 x "-k")
1226 (==ucs@ks "u" 4 x "-k")
1227 (===ucs@ks "u" 4 x "-k")
1228 (=ks-x1001 "k0-" 4 x nil)
1229 (=jis-x0208@1978/1pr "j78-" 4 x nil)
1230 (=jis-x0208@1978/-4pr "j78-" 4 x nil)
1231 (=jis-x0208@1978 "j78-" 4 x nil)
1232 (=>>>jis-x0208@1978 "j78-" 4 x nil)
1233 (=>>jis-x0208@1978 "j78-" 4 x nil)
1234 (=+>jis-x0208@1978 "j78-" 4 x nil)
1235 (=ucs@JP "u" 4 x nil)
1236 (=ucs@gb "u" 4 x "-g")
1237 (=ucs@iso "u" 4 x "-u")
1238 (=ucs@unicode "u" 4 x "-us")
1239 (=big5-cdp "cdp-" 4 x nil)
1240 (=>>big5-cdp "cdp-" 4 x nil)
1241 (=cns11643-1 "c1-" 4 x nil)
1242 (=cns11643-2 "c2-" 4 x nil)
1243 (=cns11643-3 "c3-" 4 x nil)
1244 (=cns11643-4 "c4-" 4 x nil)
1245 (=cns11643-5 "c5-" 4 x nil)
1246 (=cns11643-6 "c6-" 4 x nil)
1247 (=cns11643-7 "c7-" 4 x nil)
1248 (=jis-x0208 "j90-" 4 x nil)
1249 (=>>>jis-x0208 "j90-" 4 x nil)
1250 (=>>jis-x0208 "j90-" 4 x nil)
1251 (=+>jis-x0208 "j90-" 4 x nil)
1252 (=jis-x0208@1990 "j90-" 4 x nil)
1253 (=>>>jis-x0208@1990 "j90-" 4 x nil)
1254 (=>>jis-x0208@1990 "j90-" 4 x nil)
1255 (=+>jis-x0208@1990 "j90-" 4 x nil)
1256 (=jis-x0208@1983 "j83-" 4 x nil)
1257 (=>>>jis-x0208@1983 "j83-" 4 x nil)
1258 (=>>jis-x0208@1983 "j83-" 4 x nil)
1259 (=+>jis-x0208@1983 "j83-" 4 x nil)
1260 (=cbeta "cb" 5 d nil)
1261 (=>>daikanwa "dkw-" 5 d nil)
1262 (=big5-cdp-var-3 "cdp-" 4 x "-var-3")
1263 (=big5-cdp-var-5 "cdp-" 4 x "-var-5")
1266 (defun char-GlyphWiki-id (char)
1267 (let ((rest coded-charset-GlyphWiki-id-alist)
1270 (setq spec (pop rest))
1271 (null (setq ret (char-feature char (car spec))))))
1275 (mapconcat #'char-GlyphWiki-id ret "-"))
1276 (and (memq (car spec) '(=ucs@unicode '=ucs@iso))
1278 ((and (or (encode-char char '=jis-x0208@1990)
1279 (encode-char char '=jis-x0212)
1280 (encode-char char '=jis-x0213-1)
1281 (encode-char char '=jis-x0213-2))
1282 (setq code (encode-char char '=ucs@jis)))
1283 (format "u%04x" code)
1285 ((and (or (encode-char char '=gb2312)
1286 (encode-char char '=gb12345))
1287 (setq code (encode-char char '=ucs@gb)))
1288 (format "u%04x-g" code)
1290 ((and (or (encode-char char '=cns11643-1)
1291 (encode-char char '=cns11643-2)
1292 (encode-char char '=cns11643-3)
1293 (encode-char char '=cns11643-4)
1294 (encode-char char '=cns11643-5)
1295 (encode-char char '=cns11643-6)
1296 (encode-char char '=cns11643-7))
1297 (setq code (encode-char char '=ucs@cns)))
1298 (format "u%04x-t" code)
1300 ((and (encode-char char '=ks-x1001)
1301 (setq code (encode-char char '=ucs@ks)))
1302 (format "u%04x-k" code)
1304 (format (format "%s%%0%d%s%s"
1308 (or (nth 4 spec) ""))
1315 (provide 'cwiki-common)
1317 ;;; cwiki-common.el ends here