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 (defun decode-uri-string (string &optional coding-system)
57 (if (> (length string) 0)
61 (mapconcat (lambda (char)
64 (char-to-string char)))
66 (while (string-match "%\\([0-9A-F][0-9A-F]\\)" string i)
67 (setq dest (concat dest
68 (substring string i (match-beginning 0))
71 (string-to-int (match-string 1 string) 16))))
74 (concat dest (substring string i))
77 (defun www-feature-type (feature-name)
78 (or (char-feature-property feature-name 'type)
79 (let ((str (symbol-name feature-name)))
81 ((string-match "\\*note\\(@[^*]+\\)?$" str)
83 ((string-match "\\*sources\\(@[^*]+\\)?$" str)
85 ((string-match "\\*" str)
87 ((string-match "^\\(->\\|<-\\)" str)
89 ((string-match "^ideographic-structure\\(@\\|$\\)" str)
93 (defun www-feature-format (feature-name)
94 (or (char-feature-property feature-name 'format)
96 (setq fn feature-name)
97 (while (and (setq parent (char-feature-name-parent fn))
99 (char-feature-property
103 '((name) " : " (value))))
105 (defun www-feature-value-format (feature-name)
106 (or (char-feature-property feature-name 'value-presentation-format)
107 (char-feature-property feature-name 'value-format)
109 (setq fn feature-name)
110 (while (and (setq parent (char-feature-name-parent fn))
112 (or (char-feature-property
113 parent 'value-presentation-format)
114 (char-feature-property
115 parent 'value-format)))))
118 (let ((type (www-feature-type feature-name)))
119 (cond ((eq type 'relation)
121 ((eq type 'structure)
122 'space-separated-ids)
126 (if (find-charset feature-name)
127 (if (and (= (charset-dimension feature-name) 2)
128 (= (charset-chars feature-name) 94))
130 " (" (decimal) ") <" (ku-ten) "> " (prev-char) (next-char))
131 '("0x" (HEX) " (" (decimal) ") " (prev-char) (next-char))))
134 (defun char-feature-name-at-domain (feature-name domain)
136 (let ((name (symbol-name feature-name)))
138 ((string-match "@[^*]+$" name)
139 (intern (format "%s/%s" name domain))
142 (intern (format "%s@%s" name domain))
146 (defun char-feature-name-parent (feature-name)
147 (let ((name (symbol-name feature-name)))
148 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
149 (intern (substring name 0 (car (last (match-data) 2)))))))
151 (defun char-feature-name-domain (feature-name)
152 (let ((name (symbol-name feature-name)))
153 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
154 (intern (substring name (1+ (match-beginning 0)))))))
156 (defun char-feature-name-sans-versions (feature)
157 (let ((feature-name (symbol-name feature)))
158 (if (string-match "[@/]\\$rev=latest$" feature-name)
159 (intern (substring feature-name 0 (match-beginning 0)))
162 (defun est-object-genre (object)
163 (if (characterp object)
165 (concord-object-genre object)))
167 (defun www-get-feature-value (object feature)
168 (let ((latest-feature (char-feature-name-at-domain feature '$rev=latest)))
171 (mount-char-attribute-table latest-feature)
172 (or (char-feature object latest-feature)
173 (char-feature object feature))
176 (or (condition-case nil
177 (concord-object-get object latest-feature)
180 (concord-object-get object feature)
184 (defun get-previous-code-point (ccs code)
185 (let ((chars (charset-chars ccs))
186 (dim (charset-dimension ccs))
188 mask byte-min byte-max
211 (setq bytes (make-vector dim 0))
213 (aset bytes i (logand (lsh code (* i -8)) mask))
216 (while (and (< i dim)
218 (aset bytes i (1- (aref bytes i)))
219 (< (aref bytes i) byte-min)))
220 (aset bytes i byte-max)
223 (setq dest (aref bytes 0)
226 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
230 (defun get-next-code-point (ccs code)
231 (let ((chars (charset-chars ccs))
232 (dim (charset-dimension ccs))
234 mask byte-min byte-max
257 (setq bytes (make-vector dim 0))
259 (aset bytes i (logand (lsh code (* i -8)) mask))
262 (while (and (< i dim)
264 (aset bytes i (1+ (aref bytes i)))
265 (> (aref bytes i) byte-max)))
266 (aset bytes i byte-min)
269 (setq dest (aref bytes 0)
272 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
276 (defun find-previous-defined-code-point (ccs code)
277 (let ((i (get-previous-code-point ccs code))
280 ((eq ccs '=jis-x0208)
281 (setq ccs '=jis-x0208@1990))
282 ((eq ccs '=jis-x0213-1)
283 (setq ccs '=jis-x0213-1@2004)))
286 (null (setq char (decode-char ccs i
287 (unless (eq ccs '=ucs)
289 (setq i (get-previous-code-point ccs i)))
292 (defun find-next-defined-code-point (ccs code)
293 (let ((i (get-next-code-point ccs code))
295 (setq max (+ code 1000))
297 ((eq ccs '=jis-x0208)
298 (setq ccs '=jis-x0208@1990))
299 ((eq ccs '=jis-x0213-1)
300 (setq ccs '=jis-x0213-1@2004)))
303 (null (setq char (decode-char ccs i
304 (unless (eq ccs '=ucs)
306 (setq i (get-next-code-point ccs i)))
310 ;;; @ URI representation
313 (defun est-uri-decode-feature-name-body (uri-feature)
314 (let ((len (length uri-feature))
321 (if (eq (aref uri-feature i) ?\.)
322 (if (and (< (+ i 2) len)
323 (eq (aref uri-feature (+ i 2)) ?\.))
326 ((eq (setq ch (aref uri-feature (1+ i))) ?\.)
331 (substring uri-feature i (+ i 3))
337 (char-to-string (aref uri-feature i))
341 (defun est-uri-encode-feature-name-body (feature)
342 (mapconcat (lambda (c)
347 (t (char-to-string c))))
350 (defun www-uri-decode-feature-name (uri-feature)
352 (setq uri-feature (decode-uri-string uri-feature 'utf-8-mcs-er))
354 ((string-match "^from\\." uri-feature)
355 (intern (format "<-%s"
356 (est-uri-decode-feature-name-body
357 (substring uri-feature (match-end 0)))))
359 ((string-match "^to\\." uri-feature)
360 (intern (format "->%s"
361 (est-uri-decode-feature-name-body
362 (substring uri-feature (match-end 0)))))
364 ((string-match "^rep\\." uri-feature)
365 (intern (format "=%s"
366 (est-uri-decode-feature-name-body
367 (substring uri-feature (match-end 0)))))
369 ((string-match "^rep[2i]\\." uri-feature)
370 (intern (format "===%s"
371 (est-uri-decode-feature-name-body
372 (substring uri-feature (match-end 0)))))
374 ((string-match "^g\\." uri-feature)
375 (intern (format "=>>%s"
376 (est-uri-decode-feature-name-body
377 (substring uri-feature (match-end 0)))))
379 ((string-match "^g[i2]\\." uri-feature)
380 (intern (format "==%s"
381 (est-uri-decode-feature-name-body
382 (substring uri-feature (match-end 0)))))
384 ((string-match "^gi\\([0-9]+\\)\\." uri-feature)
385 (intern (format "=>>%s%s"
386 (make-string (string-to-int
387 (match-string 1 uri-feature))
389 (est-uri-decode-feature-name-body
390 (substring uri-feature (match-end 0)))))
392 ((string-match "^o\\." uri-feature)
393 (intern (format "=+>%s"
394 (est-uri-decode-feature-name-body
395 (substring uri-feature (match-end 0)))))
397 ((string-match "^a\\." uri-feature)
398 (intern (format "=>%s"
399 (est-uri-decode-feature-name-body
400 (substring uri-feature (match-end 0)))))
402 ((string-match "^a\\([0-9]+\\)\\." uri-feature)
403 (intern (format "%s>%s"
404 (make-string (string-to-int
405 (match-string 1 uri-feature))
407 (est-uri-decode-feature-name-body
408 (substring uri-feature (match-end 0)))))
410 ((and (setq uri-feature (est-uri-decode-feature-name-body uri-feature))
411 (setq feature (intern (format "=>%s" uri-feature)))
412 (find-charset feature))
414 ((and (setq feature (intern (format "=>>%s" uri-feature)))
415 (find-charset feature))
417 ((and (setq feature (intern (format "=>>>%s" uri-feature)))
418 (find-charset feature))
420 ((and (setq feature (intern (format "=%s" uri-feature)))
421 (find-charset feature))
423 (t (intern uri-feature)))))
425 (defun www-uri-encode-feature-name (feature-name)
426 (setq feature-name (symbol-name feature-name))
428 ((string-match "^=\\+>\\([^=>]+\\)" feature-name)
430 (est-uri-encode-feature-name-body
431 (substring feature-name (match-beginning 1))))
433 ((string-match "^=\\([^=>]+\\)" feature-name)
435 (est-uri-encode-feature-name-body
436 (substring feature-name (match-beginning 1))))
438 ((string-match "^==\\([^=>]+\\)" feature-name)
440 (est-uri-encode-feature-name-body
441 (substring feature-name (match-beginning 1))))
443 ((string-match "^===\\([^=>]+\\)" feature-name)
445 (est-uri-encode-feature-name-body
446 (substring feature-name (match-beginning 1))))
448 ((string-match "^=>>\\([^=>]+\\)" feature-name)
450 (est-uri-encode-feature-name-body
451 (substring feature-name (match-beginning 1))))
453 ((string-match "^=>>>\\([^=>]+\\)" feature-name)
455 (est-uri-encode-feature-name-body
456 (substring feature-name (match-beginning 1))))
458 ((string-match "^=>>\\(>+\\)" feature-name)
460 (length (match-string 1 feature-name))
461 (est-uri-encode-feature-name-body
462 (substring feature-name (match-end 1))))
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 (length (match-string 1 feature-name))
472 (est-uri-encode-feature-name-body
473 (substring feature-name (match-end 0))))
475 ((string-match "^->" feature-name)
477 (est-uri-encode-feature-name-body
478 (substring feature-name (match-end 0))))
480 ((string-match "^<-" feature-name)
482 (est-uri-encode-feature-name-body
483 (substring feature-name (match-end 0))))
485 (t (est-uri-encode-feature-name-body feature-name))))
487 (defun www-uri-make-feature-name-url (uri-genre uri-feature-name uri-object)
488 (if est-hide-cgi-mode
489 (format "../feature/%s&%s/%s"
490 uri-feature-name uri-genre uri-object)
491 (format "%s?feature=%s&%s=%s"
492 chise-wiki-view-url uri-feature-name uri-genre uri-object)))
494 (defun www-uri-decode-object (genre char-rep)
497 ((string-match (if est-hide-cgi-mode
498 "\\(%3D\\|=\\|%3A\\|:\\)"
499 "\\(%3A\\|:\\)") char-rep)
500 (setq ccs (substring char-rep 0 (match-beginning 0))
501 cpos (substring char-rep (match-end 0)))
502 (setq ccs (www-uri-decode-feature-name ccs))
503 (setq cpos (est-uri-decode-feature-name-body cpos))
505 ((string-match "^0x" cpos)
507 (string-to-number (substring cpos (match-end 0)) 16))
510 (setq cpos (car (read-from-string
512 cpos file-name-coding-system))))
514 (if (and (eq genre 'character)
516 (decode-char ccs cpos)
517 (concord-decode-object ccs cpos genre))
520 (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er))
522 ((eq genre 'character)
523 (when (= (length char-rep) 1)
527 (concord-decode-object
528 '=id (www-uri-decode-feature-name char-rep) 'feature)
531 (concord-decode-object
532 '=id (car (read-from-string char-rep)) genre)
535 (defun www-uri-encode-object (object)
536 (if (characterp object)
537 (if (encode-char object '=ucs)
540 (format "%%%02X" byte))
541 (encode-coding-string (char-to-string object) 'utf-8-mcs-er)
543 (let ((ccs-list '(; =ucs
544 =cns11643-1 =cns11643-2 =cns11643-3
545 =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7
547 =jis-x0208 =jis-x0208@1990
552 =jis-x0213-1@2000 =jis-x0213-1@2004
553 =jis-x0208@1983 =jis-x0208@1978
554 =zinbun-oracle =>zinbun-oracle
558 =>>>jis-x0208 =>>>jis-x0213-1 =>>>jis-x0213-2
559 =>>jis-x0208 =>>jis-x0213-1 =>>jis-x0213-2
561 =+>jis-x0208 =+>jis-x0213-1 =+>jis-x0213-2
564 =>jis-x0208 =>jis-x0213-1
566 =>ucs@iso =>ucs@unicode
567 =>ucs@jis =>ucs@cns =>ucs@ks
568 =>>ucs@iso =>>ucs@unicode
569 =>>ucs@jis =>>ucs@cns =>>ucs@ks
570 =>>>ucs@iso =>>>ucs@unicode
571 =>>>ucs@jis =>>>ucs@cns =>>>ucs@ks
577 (setq ccs (pop ccs-list))
578 (not (setq ret (encode-char object ccs 'defined-only)))))
580 (format (if est-hide-cgi-mode
583 (www-uri-encode-feature-name ccs)
585 ((and (setq ccs (car (split-char object)))
586 (setq ret (encode-char object ccs)))
587 (format (if est-hide-cgi-mode
590 (www-uri-encode-feature-name ccs)
593 (format (if est-hide-cgi-mode
594 "system-char-id=0x%X"
595 "system-char-id:0x%X")
596 (encode-char object 'system-char-id))
598 (format (if est-hide-cgi-mode
601 (est-uri-encode-feature-name-body
602 (format "%s" (concord-object-id object))))))
604 (defun est-format-object (object &optional readable)
605 (if (characterp object)
606 (char-to-string object)
607 (let ((ret (or (if readable
608 (or (concord-object-get object 'name)
609 (concord-object-get object '=name)
610 (concord-object-get object 'title)))
611 (concord-object-id object))))
614 (defun www-uri-make-object-url (object &optional uri-object)
615 (if est-hide-cgi-mode
618 (est-object-genre object)
620 (www-uri-encode-object object)))
623 (est-object-genre object)
625 (www-uri-encode-object object)))))
628 ;;; @ Feature name presentation
631 (defun www-format-feature-name-default (feature-name)
635 (symbol-name feature-name)
639 (defun www-format-feature-name-as-metadata (feature-name &optional lang)
640 (let ((str (symbol-name feature-name))
643 ((string-match "\\*[^*]+$" str)
644 (setq base (substring str 0 (match-beginning 0))
645 meta (substring str (match-beginning 0)))
646 (concat (www-format-feature-name* (intern base) lang)
649 (www-format-feature-name-default feature-name)
652 (defun www-format-feature-name-as-rel-to (feature-name)
653 (concat "\u2192" (substring (symbol-name feature-name) 2)))
655 (defun www-format-feature-name-as-rel-from (feature-name)
656 (concat "\u2190" (substring (symbol-name feature-name) 2)))
658 (defun www-format-feature-name-as-CCS (feature-name)
661 (symbol-name feature-name)
663 (dest (upcase (pop rest))))
664 (when (string-match "^=+>*" dest)
665 (setq dest (concat (substring dest 0 (match-end 0))
667 (substring dest (match-end 0)))))
671 (setq dest (concat dest " " (upcase (pop rest)))))
672 (if (string-match "^[0-9]+$" (car rest))
673 (concat dest "-" (car rest))
674 (concat dest " " (upcase (car rest))))
678 (defun www-format-feature-name* (feature-name &optional lang)
679 (let (name fn parent ret)
682 (char-feature-property
684 (intern (format "name@%s" lang))))
685 (char-feature-property
686 feature-name 'name)))
687 ((and (setq name (symbol-name feature-name))
688 (string-match "\\*" name))
689 (www-format-feature-name-as-metadata feature-name lang))
691 (setq fn feature-name)
692 (while (and (setq parent (char-feature-name-parent fn))
695 (char-feature-property
697 (intern (format "name@%s" lang))))
698 (char-feature-property
703 (concat ret (substring (symbol-name feature-name)
704 (length (symbol-name parent)))))
705 ((find-charset feature-name)
706 (www-format-feature-name-as-CCS feature-name))
707 ((string-match "^\\(->\\)" name)
708 (www-format-feature-name-as-rel-to feature-name))
709 ((string-match "^\\(<-\\)" name)
710 (www-format-feature-name-as-rel-from feature-name))
712 (www-format-feature-name-default feature-name)
716 (defun www-format-feature-name (feature-name &optional lang)
717 (www-format-encode-string
718 (www-format-feature-name* feature-name lang)))
724 (defvar www-format-char-img-style "vertical-align:bottom;")
726 (defun www-format-encode-string (string &optional without-tags as-body)
729 (let (plane code subcode start end char variants ret rret)
731 (goto-char (point-min))
732 (while (search-forward "&" nil t)
733 (replace-match "&" nil t)))
734 (goto-char (point-min))
735 (while (search-forward "<" nil t)
736 (replace-match "<" nil t))
737 (goto-char (point-min))
738 (while (search-forward ">" nil t)
739 (replace-match ">" nil t))
741 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
742 (let ((coded-charset-entity-reference-alist
745 '(=hanyo-denshi/ja "HD-JA-" 4 X)
746 '(=hanyo-denshi/jb "HD-JB-" 4 X)
747 '(=hanyo-denshi/jc "HD-JC-" 4 X)
748 '(=hanyo-denshi/jd "HD-JD-" 4 X)
749 '(=hanyo-denshi/ft "HD-FT-" 4 X)
750 '(=hanyo-denshi/ia "HD-IA-" 4 X)
751 '(=hanyo-denshi/ib "HD-IB-" 4 X)
752 '(=hanyo-denshi/hg "HD-HG-" 4 X)
753 '(=hanyo-denshi/ip "HD-IP-" 4 X)
754 '(=hanyo-denshi/jt "HD-JT-" 4 X)
755 '(=hanyo-denshi/ks "HD-KS-" 6 d)
756 '(=>>hanyo-denshi/ja "G-HD-JA-" 4 X)
757 '(=>>hanyo-denshi/jb "G-HD-JB-" 4 X)
758 '(=>>hanyo-denshi/jc "G-HD-JC-" 4 X)
759 '(=>>hanyo-denshi/jd "G-HD-JD-" 4 X)
760 '(=>>hanyo-denshi/ft "G-HD-FT-" 4 X)
761 '(=>>hanyo-denshi/ia "G-HD-IA-" 4 X)
762 '(=>>hanyo-denshi/ib "G-HD-IB-" 4 X)
763 '(=>>hanyo-denshi/hg "G-HD-HG-" 4 X)
764 '(=>>hanyo-denshi/ip "G-HD-IP-" 4 X)
765 '(=>>hanyo-denshi/jt "G-HD-JT-" 4 X)
766 '(=>>hanyo-denshi/ks "G-HD-KS-" 6 d)
767 '(==hanyo-denshi/ja "g2-HD-JA-" 4 X)
768 '(==hanyo-denshi/jb "g2-HD-JB-" 4 X)
769 '(==hanyo-denshi/jc "g2-HD-JC-" 4 X)
770 '(==hanyo-denshi/jd "g2-HD-JD-" 4 X)
771 '(==hanyo-denshi/ft "g2-HD-FT-" 4 X)
772 '(==hanyo-denshi/ia "g2-HD-IA-" 4 X)
773 '(==hanyo-denshi/ib "g2-HD-IB-" 4 X)
774 '(==hanyo-denshi/hg "g2-HD-HG-" 4 X)
775 '(==hanyo-denshi/ip "g2-HD-IP-" 4 X)
776 '(==hanyo-denshi/jt "g2-HD-JT-" 4 X)
777 '(==hanyo-denshi/ks "g2-HD-KS-" 6 d)
778 '(=cns11643-1 "C1-" 4 X)
779 '(=cns11643-2 "C2-" 4 X)
780 '(=cns11643-3 "C3-" 4 X)
781 '(=cns11643-4 "C4-" 4 X)
782 '(=cns11643-5 "C5-" 4 X)
783 '(=cns11643-6 "C6-" 4 X)
784 '(=cns11643-7 "C7-" 4 X)
785 '(=adobe-japan1-6 "AJ1-" 5 d)
786 '(=big5-cdp "CDP-" 4 X)
788 '(=gb12345 "G1-" 4 X)
789 '(=jis-x0208@1990 "J90-" 4 X)
790 '(=jis-x0212 "JSP-" 4 X)
792 '(=jis-x0208@1997 "J97-" 4 X)
793 '(=jis-x0208@1978 "J78-" 4 X)
794 '(=jis-x0208@1983 "J83-" 4 X)
795 '(=ruimoku-v6 "RUI6-" 4 X)
796 '(=zinbun-oracle "ZOB-" 4 d)
797 '(=jef-china3 "JC3-" 4 X)
798 '(=ucs@unicode "UU+" 4 X)
799 '(=ucs@JP/hanazono "hanaJU+" 4 X)
800 '(=daikanwa "M-" 5 d)
801 '(==cns11643-1 "R-C1-" 4 X)
802 '(==cns11643-2 "R-C2-" 4 X)
803 '(==cns11643-3 "R-C3-" 4 X)
804 '(==cns11643-4 "R-C4-" 4 X)
805 '(==cns11643-5 "R-C5-" 4 X)
806 '(==cns11643-6 "R-C6-" 4 X)
807 '(==cns11643-7 "R-C7-" 4 X)
808 coded-charset-entity-reference-alist)))
809 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
811 (goto-char (point-min))
812 (while (re-search-forward "&CB\\([0-9]+\\);" nil t)
813 (setq code (string-to-int (match-string 1)))
815 (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
818 chise-wiki-bitmap-glyphs-url
820 www-format-char-img-style)
823 (goto-char (point-min))
824 (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)
825 (setq plane (match-string 2)
826 code (string-to-int (match-string 3) 16))
828 (format "<img alt=\"J%s-%04X\" src=\"%s/JIS-%s/%02d-%02d.gif\"
831 chise-wiki-bitmap-glyphs-url
834 (- (logand code 255) 32)
835 www-format-char-img-style)
838 (goto-char (point-min))
839 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?J0-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
840 (setq code (string-to-int (match-string 2) 16))
842 (format "<img alt=\"J0-%04X\" src=\"%s/JIS-90/%02d-%02d.gif\"
845 chise-wiki-bitmap-glyphs-url
847 (- (logand code 255) 32)
848 www-format-char-img-style)
851 (goto-char (point-min))
852 (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)
853 (setq plane (match-string 2)
854 code (string-to-int (match-string 3) 16))
856 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%02d%02d.png\"
859 chise-wiki-bitmap-glyphs-url
862 (- (logand code 255) 32)
863 www-format-char-img-style)
866 (goto-char (point-min))
867 (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)
868 (setq plane (match-string 2)
869 code (string-to-int (match-string 3) 16))
871 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%04X.png\"
874 chise-wiki-bitmap-glyphs-url
876 www-format-char-img-style)
879 (goto-char (point-min))
880 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-KS-\\([0-9]+\\);" nil t)
881 (setq code (string-to-int (match-string 2)))
883 (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/KS%06d.png\"
884 style=\"vertical-align:middle\">"
886 chise-wiki-bitmap-glyphs-url
888 www-format-char-img-style)
891 (goto-char (point-min))
892 (while (re-search-forward "&G\\([01]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
893 (setq plane (string-to-int (match-string 1))
894 code (string-to-int (match-string 2) 16))
896 (format "<img alt=\"GB%d-%04X\" src=\"%s/GB%d/%02d-%02d.gif\"
899 chise-wiki-bitmap-glyphs-url
902 (- (logand code 255) 32)
903 www-format-char-img-style)
906 (goto-char (point-min))
907 (while (re-search-forward "&\\(R-\\)?C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
908 (setq plane (string-to-int (match-string 2))
909 code (string-to-int (match-string 3) 16))
911 (format "<img alt=\"CNS%d-%04X\" src=\"%s/CNS%d/%04X.gif\"
914 chise-wiki-bitmap-glyphs-url
916 www-format-char-img-style)
919 (goto-char (point-min))
920 (while (re-search-forward "&\\(R-\\)?JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
921 (setq code (string-to-int (match-string 2) 16))
923 (format "<img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">"
927 (goto-char (point-min))
928 (while (re-search-forward "&\\(A-\\)?ZOB-\\([0-9]+\\);" nil t)
929 (setq code (string-to-int (match-string 2)))
931 (format "<img alt=\"ZOB-%04d\" src=\"%s/ZOB-1968/%04d.png\"
932 style=\"vertical-align:middle\">"
934 chise-wiki-bitmap-glyphs-url
936 www-format-char-img-style)
939 (goto-char (point-min))
940 (while (re-search-forward "&HNG\\([0-9]+\\)-\\([0-9][0-9][0-9][0-9]\\)\\([0-9]\\);" nil t)
941 (setq plane (match-string 1)
942 code (string-to-int (match-string 2))
943 subcode (string-to-int (match-string 3)))
947 (char-to-string (decode-char 'ascii (+ 96 subcode)))))
950 "<img alt=\"HNG%s-%04d%s\" src=\"%s/%s/%04d%s.png\"
951 style=\"vertical-align:middle; width: 48px; height: 48px\">"
953 chise-wiki-hng-bitmap-glyphs-url
955 www-format-char-img-style)
958 (goto-char (point-min))
959 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?AJ1-\\([0-9]+\\);" nil t)
960 (setq code (string-to-int (match-string 2)))
962 (format "<img alt=\"AJ1-%05d\" src=\"%s/IVD/AdobeJapan1/CID+%d.png\"
963 style=\"vertical-align:middle\">"
965 chise-wiki-bitmap-glyphs-url
967 www-format-char-img-style)
970 (goto-char (point-min))
971 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?MJ\\([0-9]+\\);" nil t)
972 (setq code (string-to-int (match-string 2)))
974 (format "<img alt=\"MJ%06d\" src=\"http://mojikiban.ipa.go.jp/search/MJ%06d\"
975 style=\"vertical-align:middle; width: 48px; height: 48px\">"
978 www-format-char-img-style)
981 (goto-char (point-min))
982 (while (re-search-forward "&\\(G-\\|R-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
983 (setq code (string-to-int (match-string 2)))
985 (format "<img alt=\"GT-%05d\" src=\"%s?char=GT-%05d\"
988 chise-wiki-glyph-cgi-url
990 www-format-char-img-style)
993 (goto-char (point-min))
994 (while (re-search-forward "&\\(G-\\)?GT-K\\([0-9]+\\);" nil t)
995 (setq code (string-to-int (match-string 2)))
997 (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\"
1000 chise-wiki-glyph-cgi-url
1002 www-format-char-img-style)
1005 (goto-char (point-min))
1006 (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
1007 (setq code (string-to-int (match-string 1) 16))
1009 (format "<img alt=\"B-%04X\" src=\"%s?char=B-%04X\"
1012 chise-wiki-glyph-cgi-url
1014 www-format-char-img-style)
1017 (goto-char (point-min))
1018 (while (re-search-forward "&\\(G-\\|g2-\\|R-\\)?CDP-\\([0-9A-F]+\\);" nil t)
1019 (setq code (string-to-int (match-string 2) 16))
1021 (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
1024 chise-wiki-glyph-cgi-url
1026 www-format-char-img-style)
1029 (goto-char (point-min))
1030 (while (re-search-forward "&RUI6-\\([0-9A-F]+\\);" nil t)
1031 (setq code (string-to-int (match-string 1) 16))
1033 (format "<img alt=\"RUI6-%04X\" src=\"%s?char=RUI6-%04X\"
1034 style=\"vertical-align:middle\">"
1036 chise-wiki-glyph-cgi-url
1038 www-format-char-img-style)
1041 (goto-char (point-min))
1042 (while (re-search-forward "&hanaJU\\+\\([0-9A-F]+\\);" nil t)
1043 (setq code (string-to-int (match-string 1) 16))
1045 (format "<img alt=\"hanaJU+%04X\" src=\"%s?char=hana-JU+%04X\"
1046 style=\"vertical-align:middle\">"
1048 chise-wiki-glyph-cgi-url
1050 www-format-char-img-style)
1053 (goto-char (point-min))
1054 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\|R-\\)?\\(UU\\+\\|U-\\)\\([0-9A-F]+\\);" nil t)
1055 (setq code (string-to-int (match-string 3) 16))
1057 (format "<img alt=\"UU+%04X\" src=\"http://www.unicode.org/cgi-bin/refglyph?24-%04X\"
1058 style=\"vertical-align:middle\">"
1061 www-format-char-img-style)
1064 (goto-char (point-min))
1065 (while (re-search-forward "&MCS-\\([0-9A-F]+\\);" nil t)
1066 (setq code (string-to-int (match-string 1) 16))
1067 (setq start (match-beginning 0)
1069 (setq char (decode-char 'system-char-id code))
1071 ((and (setq variants
1072 (or (www-get-feature-value char '->subsumptive)
1073 (www-get-feature-value char '->denotational)))
1075 (while (and variants
1076 (setq ret (www-format-encode-string
1077 (char-to-string (car variants))))
1078 (string-match "&MCS-\\([0-9A-F]+\\);" ret))
1079 (setq variants (cdr variants)))
1081 (unless (string-match "&MCS-\\([0-9A-F]+\\);" ret)
1083 (delete-region start end)
1086 ((setq ret (or (www-get-feature-value char 'ideographic-combination)
1087 (www-get-feature-value char 'ideographic-structure)))
1092 (if (characterp (setq rret (find-char ch)))
1095 (www-format-encode-string
1096 (char-to-string ch) without-tags)
1097 (www-format-encode-string
1098 (format "%S" ch) without-tags)))
1102 (delete-region start end)
1106 ;; (goto-char (point-min))
1107 ;; (while (search-forward ">-" nil t)
1108 ;; (replace-match "&GT-" t 'literal))
1111 (defun www-html-display-text (text)
1115 (goto-char (point-min))
1116 (while (search-forward "<" nil t)
1117 (replace-match "<" nil t))
1118 (goto-char (point-min))
1119 (while (search-forward ">" nil t)
1120 (replace-match ">" nil t))
1121 (goto-char (point-min))
1122 (while (re-search-forward "\\[\\[\\([^]|[]+\\)|\\([^][]+\\)\\]\\]" nil t)
1124 (format "<a href=\"%s\">%s</a>"
1128 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
1129 (goto-char (point-min))
1130 (while (search-forward ">-" nil t)
1131 (replace-match "&GT-" nil t))
1134 (defun www-html-display-paragraph (text)
1136 (www-html-display-text text)
1143 (defvar coded-charset-GlyphWiki-id-alist
1144 '((=ucs "u" 4 x nil)
1145 (=adobe-japan1-0 "aj1-" 5 d nil)
1146 (=adobe-japan1-1 "aj1-" 5 d nil)
1147 (=adobe-japan1-2 "aj1-" 5 d nil)
1148 (=adobe-japan1-3 "aj1-" 5 d nil)
1149 (=adobe-japan1-4 "aj1-" 5 d nil)
1150 (=adobe-japan1-5 "aj1-" 5 d nil)
1151 (=adobe-japan1-6 "aj1-" 5 d nil)
1152 (==adobe-japan1-0 "aj1-" 5 d nil)
1153 (==adobe-japan1-1 "aj1-" 5 d nil)
1154 (==adobe-japan1-2 "aj1-" 5 d nil)
1155 (==adobe-japan1-3 "aj1-" 5 d nil)
1156 (==adobe-japan1-4 "aj1-" 5 d nil)
1157 (==adobe-japan1-5 "aj1-" 5 d nil)
1158 (==adobe-japan1-6 "aj1-" 5 d nil)
1159 (===adobe-japan1-0 "aj1-" 5 d nil)
1160 (===adobe-japan1-1 "aj1-" 5 d nil)
1161 (===adobe-japan1-2 "aj1-" 5 d nil)
1162 (===adobe-japan1-3 "aj1-" 5 d nil)
1163 (===adobe-japan1-4 "aj1-" 5 d nil)
1164 (===adobe-japan1-5 "aj1-" 5 d nil)
1165 (===adobe-japan1-6 "aj1-" 5 d nil)
1166 (=decomposition@cid)
1167 (=decomposition@hanyo-denshi)
1168 (=hanyo-denshi/ks "koseki-" 6 d nil)
1169 (=>>hanyo-denshi/ks "koseki-" 6 d nil)
1170 (=ucs@jis "u" 4 x nil)
1171 (==ucs@jis "u" 4 x nil)
1172 (===ucs@jis "u" 4 x nil)
1173 (=ucs@cns "u" 4 x "-t")
1174 (==ucs@cns "u" 4 x "-t")
1175 (=jis-x0212 "jsp-" 4 x nil)
1176 (=jis-x0213-1@2000 "jx1-2000-" 4 x nil)
1177 (=jis-x0213-1@2004 "jx1-2004-" 4 x nil)
1178 (=jis-x0213-2 "jx2-" 4 x nil)
1180 (=daikanwa "dkw-" 5 d nil)
1181 (==daikanwa "dkw-" 5 d nil)
1182 (===daikanwa "dkw-" 5 d nil)
1183 (=gt-k "gt-k" 5 d nil)
1184 (=jef-china3 "jc3-" 4 x nil)
1185 (=big5 "b-" 4 x nil)
1186 (=ucs@ks "u" 4 x "-k")
1187 (==ucs@ks "u" 4 x "-k")
1188 (===ucs@ks "u" 4 x "-k")
1189 (=ks-x1001 "k0-" 4 x nil)
1190 (=jis-x0208@1978/1pr "j78-" 4 x nil)
1191 (=jis-x0208@1978/-4pr "j78-" 4 x nil)
1192 (=jis-x0208@1978 "j78-" 4 x nil)
1193 (=>>>jis-x0208@1978 "j78-" 4 x nil)
1194 (=>>jis-x0208@1978 "j78-" 4 x nil)
1195 (=+>jis-x0208@1978 "j78-" 4 x nil)
1196 (=ucs@JP "u" 4 x nil)
1197 (=ucs@gb "u" 4 x "-g")
1198 (=ucs@iso "u" 4 x "-u")
1199 (=ucs@unicode "u" 4 x "-us")
1200 (=big5-cdp "cdp-" 4 x nil)
1201 (=>>big5-cdp "cdp-" 4 x nil)
1202 (=cns11643-1 "c1-" 4 x nil)
1203 (=cns11643-2 "c2-" 4 x nil)
1204 (=cns11643-3 "c3-" 4 x nil)
1205 (=cns11643-4 "c4-" 4 x nil)
1206 (=cns11643-5 "c5-" 4 x nil)
1207 (=cns11643-6 "c6-" 4 x nil)
1208 (=cns11643-7 "c7-" 4 x nil)
1209 (=jis-x0208 "j90-" 4 x nil)
1210 (=>>>jis-x0208 "j90-" 4 x nil)
1211 (=>>jis-x0208 "j90-" 4 x nil)
1212 (=+>jis-x0208 "j90-" 4 x nil)
1213 (=jis-x0208@1990 "j90-" 4 x nil)
1214 (=>>>jis-x0208@1990 "j90-" 4 x nil)
1215 (=>>jis-x0208@1990 "j90-" 4 x nil)
1216 (=+>jis-x0208@1990 "j90-" 4 x nil)
1217 (=jis-x0208@1983 "j83-" 4 x nil)
1218 (=>>>jis-x0208@1983 "j83-" 4 x nil)
1219 (=>>jis-x0208@1983 "j83-" 4 x nil)
1220 (=+>jis-x0208@1983 "j83-" 4 x nil)
1221 (=cbeta "cb" 5 d nil)
1222 (=>>daikanwa "dkw-" 5 d nil)
1225 (defun char-GlyphWiki-id (char)
1226 (let ((rest coded-charset-GlyphWiki-id-alist)
1229 (setq spec (pop rest))
1230 (null (setq ret (char-feature char (car spec))))))
1234 (mapconcat #'char-GlyphWiki-id ret "-"))
1235 (and (memq (car spec) '(=ucs@unicode '=ucs@iso))
1237 ((and (or (encode-char char '=jis-x0208@1990)
1238 (encode-char char '=jis-x0212)
1239 (encode-char char '=jis-x0213-1)
1240 (encode-char char '=jis-x0213-2))
1241 (setq code (encode-char char '=ucs@jis)))
1242 (format "u%04x" code)
1244 ((and (or (encode-char char '=gb2312)
1245 (encode-char char '=gb12345))
1246 (setq code (encode-char char '=ucs@gb)))
1247 (format "u%04x-g" code)
1249 ((and (or (encode-char char '=cns11643-1)
1250 (encode-char char '=cns11643-2)
1251 (encode-char char '=cns11643-3)
1252 (encode-char char '=cns11643-4)
1253 (encode-char char '=cns11643-5)
1254 (encode-char char '=cns11643-6)
1255 (encode-char char '=cns11643-7))
1256 (setq code (encode-char char '=ucs@cns)))
1257 (format "u%04x-t" code)
1259 ((and (encode-char char '=ks-x1001)
1260 (setq code (encode-char char '=ucs@ks)))
1261 (format "u%04x-k" code)
1263 (format (format "%s%%0%d%s%s"
1267 (or (nth 4 spec) ""))
1274 (provide 'cwiki-common)
1276 ;;; cwiki-common.el ends here