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 'presentation-format)
95 (char-feature-property feature-name 'format)
97 (setq fn feature-name)
98 (while (and (setq parent (char-feature-name-parent fn))
100 (char-feature-property
104 '((name) " : " (value))))
106 (defun www-feature-value-format (feature-name)
107 (or (char-feature-property feature-name 'value-presentation-format)
108 (char-feature-property feature-name 'value-format)
110 (setq fn feature-name)
111 (while (and (setq parent (char-feature-name-parent fn))
113 (or (char-feature-property
114 parent 'value-presentation-format)
115 (char-feature-property
116 parent 'value-format)))))
119 (let ((type (www-feature-type feature-name)))
120 (cond ((eq type 'relation)
122 ((eq type 'structure)
123 'space-separated-ids)
127 (if (find-charset feature-name)
128 (if (and (= (charset-dimension feature-name) 2)
129 (= (charset-chars feature-name) 94))
131 " (" (decimal) ") <" (ku-ten) "> " (prev-char) (next-char))
132 '("0x" (HEX) " (" (decimal) ") " (prev-char) (next-char))))
135 (defun char-feature-name-at-domain (feature-name domain)
137 (let ((name (symbol-name feature-name)))
139 ((string-match "@[^*]+$" name)
140 (intern (format "%s/%s" name domain))
143 (intern (format "%s@%s" name domain))
147 (defun char-feature-name-parent (feature-name)
148 (let ((name (symbol-name feature-name)))
149 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
150 (intern (substring name 0 (car (last (match-data) 2)))))))
152 (defun char-feature-name-domain (feature-name)
153 (let ((name (symbol-name feature-name)))
154 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
155 (intern (substring name (1+ (match-beginning 0)))))))
157 (defun char-feature-name-sans-versions (feature)
158 (let ((feature-name (symbol-name feature)))
159 (if (string-match "[@/]\\$rev=latest$" feature-name)
160 (intern (substring feature-name 0 (match-beginning 0)))
163 (defun est-object-genre (object)
164 (if (characterp object)
166 (concord-object-genre object)))
168 (defun www-get-feature-value (object feature)
169 (let ((latest-feature (char-feature-name-at-domain feature '$rev=latest)))
172 (mount-char-attribute-table latest-feature)
173 (or (char-feature object latest-feature)
174 (char-feature object feature))
177 (or (condition-case nil
178 (concord-object-get object latest-feature)
181 (concord-object-get object feature)
185 (defun get-previous-code-point (ccs code)
186 (let ((chars (charset-chars ccs))
187 (dim (charset-dimension ccs))
189 mask byte-min byte-max
212 (setq bytes (make-vector dim 0))
214 (aset bytes i (logand (lsh code (* i -8)) mask))
217 (while (and (< i dim)
219 (aset bytes i (1- (aref bytes i)))
220 (< (aref bytes i) byte-min)))
221 (aset bytes i byte-max)
224 (setq dest (aref bytes 0)
227 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
231 (defun get-next-code-point (ccs code)
232 (let ((chars (charset-chars ccs))
233 (dim (charset-dimension ccs))
235 mask byte-min byte-max
258 (setq bytes (make-vector dim 0))
260 (aset bytes i (logand (lsh code (* i -8)) mask))
263 (while (and (< i dim)
265 (aset bytes i (1+ (aref bytes i)))
266 (> (aref bytes i) byte-max)))
267 (aset bytes i byte-min)
270 (setq dest (aref bytes 0)
273 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
277 (defun find-previous-defined-code-point (ccs code)
278 (let ((i (get-previous-code-point ccs code))
281 ((eq ccs '=jis-x0208)
282 (setq ccs '=jis-x0208@1990))
283 ((eq ccs '=jis-x0213-1)
284 (setq ccs '=jis-x0213-1@2004)))
287 (null (setq char (decode-char ccs i
288 (unless (eq ccs '=ucs)
290 (setq i (get-previous-code-point ccs i)))
293 (defun find-next-defined-code-point (ccs code)
294 (let ((i (get-next-code-point ccs code))
296 (setq max (+ code 1000))
298 ((eq ccs '=jis-x0208)
299 (setq ccs '=jis-x0208@1990))
300 ((eq ccs '=jis-x0213-1)
301 (setq ccs '=jis-x0213-1@2004)))
304 (null (setq char (decode-char ccs i
305 (unless (eq ccs '=ucs)
307 (setq i (get-next-code-point ccs i)))
311 ;;; @ URI representation
314 (defun est-uri-decode-feature-name-body (uri-feature)
315 (let ((len (length uri-feature))
322 (if (eq (aref uri-feature i) ?\.)
323 (if (and (< (+ i 2) len)
324 (eq (aref uri-feature (+ i 2)) ?\.))
327 ((eq (setq ch (aref uri-feature (1+ i))) ?\.)
332 (substring uri-feature i (+ i 3))
338 (char-to-string (aref uri-feature i))
342 (defun est-uri-encode-feature-name-body (feature)
343 (mapconcat (lambda (c)
348 (t (char-to-string c))))
351 (defun www-uri-decode-feature-name (uri-feature)
353 (setq uri-feature (decode-uri-string uri-feature 'utf-8-mcs-er))
355 ((string-match "^from\\." uri-feature)
356 (intern (format "<-%s"
357 (est-uri-decode-feature-name-body
358 (substring uri-feature (match-end 0)))))
360 ((string-match "^to\\." uri-feature)
361 (intern (format "->%s"
362 (est-uri-decode-feature-name-body
363 (substring uri-feature (match-end 0)))))
365 ((string-match "^rep\\." uri-feature)
366 (intern (format "=%s"
367 (est-uri-decode-feature-name-body
368 (substring uri-feature (match-end 0)))))
370 ((string-match "^rep[2i]\\." uri-feature)
371 (intern (format "===%s"
372 (est-uri-decode-feature-name-body
373 (substring uri-feature (match-end 0)))))
375 ((string-match "^g\\." uri-feature)
376 (intern (format "=>>%s"
377 (est-uri-decode-feature-name-body
378 (substring uri-feature (match-end 0)))))
380 ((string-match "^g[i2]\\." uri-feature)
381 (intern (format "==%s"
382 (est-uri-decode-feature-name-body
383 (substring uri-feature (match-end 0)))))
385 ((string-match "^gi\\([0-9]+\\)\\." uri-feature)
386 (intern (format "=>>%s%s"
387 (make-string (string-to-int
388 (match-string 1 uri-feature))
390 (est-uri-decode-feature-name-body
391 (substring uri-feature (match-end 0)))))
393 ((string-match "^o\\." uri-feature)
394 (intern (format "=+>%s"
395 (est-uri-decode-feature-name-body
396 (substring uri-feature (match-end 0)))))
398 ((string-match "^a\\." uri-feature)
399 (intern (format "=>%s"
400 (est-uri-decode-feature-name-body
401 (substring uri-feature (match-end 0)))))
403 ((string-match "^a\\([0-9]+\\)\\." uri-feature)
404 (intern (format "%s>%s"
405 (make-string (string-to-int
406 (match-string 1 uri-feature))
408 (est-uri-decode-feature-name-body
409 (substring uri-feature (match-end 0)))))
411 ((and (setq uri-feature (est-uri-decode-feature-name-body uri-feature))
412 (setq feature (intern (format "=>%s" uri-feature)))
413 (find-charset feature))
415 ((and (setq feature (intern (format "=>>%s" uri-feature)))
416 (find-charset feature))
418 ((and (setq feature (intern (format "=>>>%s" uri-feature)))
419 (find-charset feature))
421 ((and (setq feature (intern (format "=%s" uri-feature)))
422 (find-charset feature))
424 (t (intern uri-feature)))))
426 (defun www-uri-encode-feature-name (feature-name)
427 (setq feature-name (symbol-name feature-name))
429 ((string-match "^=\\+>\\([^=>]+\\)" feature-name)
431 (est-uri-encode-feature-name-body
432 (substring feature-name (match-beginning 1))))
434 ((string-match "^=\\([^=>]+\\)" feature-name)
436 (est-uri-encode-feature-name-body
437 (substring feature-name (match-beginning 1))))
439 ((string-match "^==\\([^=>]+\\)" feature-name)
441 (est-uri-encode-feature-name-body
442 (substring feature-name (match-beginning 1))))
444 ((string-match "^===\\([^=>]+\\)" feature-name)
446 (est-uri-encode-feature-name-body
447 (substring feature-name (match-beginning 1))))
449 ((string-match "^=>>\\([^=>]+\\)" feature-name)
451 (est-uri-encode-feature-name-body
452 (substring feature-name (match-beginning 1))))
454 ((string-match "^=>>>\\([^=>]+\\)" feature-name)
456 (est-uri-encode-feature-name-body
457 (substring feature-name (match-beginning 1))))
459 ((string-match "^=>>\\(>+\\)" feature-name)
461 (length (match-string 1 feature-name))
462 (est-uri-encode-feature-name-body
463 (substring feature-name (match-end 1))))
465 ((string-match "^=>\\([^=>]+\\)" feature-name)
467 (est-uri-encode-feature-name-body
468 (substring feature-name (match-beginning 1))))
470 ((string-match "^\\(=+\\)>" feature-name)
472 (length (match-string 1 feature-name))
473 (est-uri-encode-feature-name-body
474 (substring feature-name (match-end 0))))
476 ((string-match "^->" feature-name)
478 (est-uri-encode-feature-name-body
479 (substring feature-name (match-end 0))))
481 ((string-match "^<-" feature-name)
483 (est-uri-encode-feature-name-body
484 (substring feature-name (match-end 0))))
486 (t (est-uri-encode-feature-name-body feature-name))))
488 (defun www-uri-make-feature-name-url (uri-genre uri-feature-name uri-object)
489 (if est-hide-cgi-mode
490 (format "../feature/%s&%s/%s"
491 uri-feature-name uri-genre uri-object)
492 (format "%s?feature=%s&%s=%s"
493 chise-wiki-view-url uri-feature-name uri-genre uri-object)))
495 (defun www-uri-decode-object (genre char-rep)
498 ((string-match (if est-hide-cgi-mode
499 "\\(%3D\\|=\\|%3A\\|:\\)"
500 "\\(%3A\\|:\\)") char-rep)
501 (setq ccs (substring char-rep 0 (match-beginning 0))
502 cpos (substring char-rep (match-end 0)))
503 (setq ccs (www-uri-decode-feature-name ccs))
504 (setq cpos (est-uri-decode-feature-name-body cpos))
506 ((string-match "^0x" cpos)
508 (string-to-number (substring cpos (match-end 0)) 16))
511 (setq cpos (car (read-from-string
513 cpos file-name-coding-system))))
515 (if (and (eq genre 'character)
517 (decode-char ccs cpos)
518 (concord-decode-object ccs cpos genre))
521 (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er))
523 ((eq genre 'character)
524 (when (= (length char-rep) 1)
528 (concord-decode-object
529 '=id (www-uri-decode-feature-name char-rep) 'feature)
532 (concord-decode-object
533 '=id (car (read-from-string char-rep)) genre)
536 (defun www-uri-encode-object (object)
537 (if (characterp object)
538 (if (encode-char object '=ucs)
541 (format "%%%02X" byte))
542 (encode-coding-string (char-to-string object) 'utf-8-mcs-er)
544 (let ((ccs-list '(; =ucs
545 =cns11643-1 =cns11643-2 =cns11643-3
546 =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7
548 =jis-x0208 =jis-x0208@1990
553 =jis-x0213-1@2000 =jis-x0213-1@2004
554 =jis-x0208@1983 =jis-x0208@1978
555 =zinbun-oracle =>zinbun-oracle
559 =>>>jis-x0208 =>>>jis-x0213-1 =>>>jis-x0213-2
560 =>>jis-x0208 =>>jis-x0213-1 =>>jis-x0213-2
562 =+>jis-x0208 =+>jis-x0213-1 =+>jis-x0213-2
565 =>jis-x0208 =>jis-x0213-1
567 =>ucs@iso =>ucs@unicode
568 =>ucs@jis =>ucs@cns =>ucs@ks
569 =>>ucs@iso =>>ucs@unicode
570 =>>ucs@jis =>>ucs@cns =>>ucs@ks
571 =>>>ucs@iso =>>>ucs@unicode
572 =>>>ucs@jis =>>>ucs@cns =>>>ucs@ks
578 (setq ccs (pop ccs-list))
579 (not (setq ret (encode-char object ccs 'defined-only)))))
581 (format (if est-hide-cgi-mode
584 (www-uri-encode-feature-name ccs)
586 ((and (setq ccs (car (split-char object)))
587 (setq ret (encode-char object ccs)))
588 (format (if est-hide-cgi-mode
591 (www-uri-encode-feature-name ccs)
594 (format (if est-hide-cgi-mode
595 "system-char-id=0x%X"
596 "system-char-id:0x%X")
597 (encode-char object 'system-char-id))
599 (format (if est-hide-cgi-mode
602 (est-uri-encode-feature-name-body
603 (format "%s" (concord-object-id object))))))
605 (defun est-format-object (object &optional readable)
606 (if (characterp object)
607 (char-to-string object)
608 (let ((ret (or (if readable
609 (or (concord-object-get object 'name)
610 (concord-object-get object '=name)
611 (concord-object-get object 'title)))
612 (concord-object-id object))))
615 (defun www-uri-make-object-url (object &optional uri-object)
616 (if est-hide-cgi-mode
619 (est-object-genre object)
621 (www-uri-encode-object object)))
624 (est-object-genre object)
626 (www-uri-encode-object object)))))
629 ;;; @ Feature name presentation
632 (defun www-format-feature-name-default (feature-name)
636 (symbol-name feature-name)
640 (defun www-format-feature-name-as-metadata (feature-name &optional lang)
641 (let ((str (symbol-name feature-name))
644 ((string-match "\\*[^*]+$" str)
645 (setq base (substring str 0 (match-beginning 0))
646 meta (substring str (match-beginning 0)))
647 (concat (www-format-feature-name* (intern base) lang)
650 (www-format-feature-name-default feature-name)
653 (defun www-format-feature-name-as-rel-to (feature-name)
654 (concat "\u2192" (substring (symbol-name feature-name) 2)))
656 (defun www-format-feature-name-as-rel-from (feature-name)
657 (concat "\u2190" (substring (symbol-name feature-name) 2)))
659 (defun www-format-feature-name-as-CCS (feature-name)
662 (symbol-name feature-name)
664 (dest (upcase (pop rest))))
665 (when (string-match "^=+>*" dest)
666 (setq dest (concat (substring dest 0 (match-end 0))
668 (substring dest (match-end 0)))))
672 (setq dest (concat dest " " (upcase (pop rest)))))
673 (if (string-match "^[0-9]+$" (car rest))
674 (concat dest "-" (car rest))
675 (concat dest " " (upcase (car rest))))
679 (defun www-format-feature-name* (feature-name &optional lang)
680 (let (name fn parent ret)
683 (char-feature-property
685 (intern (format "name@%s" lang))))
686 (char-feature-property
687 feature-name 'name)))
688 ((and (setq name (symbol-name feature-name))
689 (string-match "\\*" name))
690 (www-format-feature-name-as-metadata feature-name lang))
692 (setq fn feature-name)
693 (while (and (setq parent (char-feature-name-parent fn))
696 (char-feature-property
698 (intern (format "name@%s" lang))))
699 (char-feature-property
704 (concat ret (substring (symbol-name feature-name)
705 (length (symbol-name parent)))))
706 ((find-charset feature-name)
707 (www-format-feature-name-as-CCS feature-name))
708 ((string-match "^\\(->\\)" name)
709 (www-format-feature-name-as-rel-to feature-name))
710 ((string-match "^\\(<-\\)" name)
711 (www-format-feature-name-as-rel-from feature-name))
713 (www-format-feature-name-default feature-name)
717 (defun www-format-feature-name (feature-name &optional lang)
718 (www-format-encode-string
719 (www-format-feature-name* feature-name lang)))
725 (defvar www-format-char-img-style "vertical-align:bottom;")
727 (defun www-format-encode-string (string &optional without-tags as-body)
730 (let (plane code subcode start end char variants ret rret)
732 (goto-char (point-min))
733 (while (search-forward "&" nil t)
734 (replace-match "&" nil t)))
735 (goto-char (point-min))
736 (while (search-forward "<" nil t)
737 (replace-match "<" nil t))
738 (goto-char (point-min))
739 (while (search-forward ">" nil t)
740 (replace-match ">" nil t))
742 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
743 (let ((coded-charset-entity-reference-alist
746 '(=hanyo-denshi/ja "HD-JA-" 4 X)
747 '(=hanyo-denshi/jb "HD-JB-" 4 X)
748 '(=hanyo-denshi/jc "HD-JC-" 4 X)
749 '(=hanyo-denshi/jd "HD-JD-" 4 X)
750 '(=hanyo-denshi/ft "HD-FT-" 4 X)
751 '(=hanyo-denshi/ia "HD-IA-" 4 X)
752 '(=hanyo-denshi/ib "HD-IB-" 4 X)
753 '(=hanyo-denshi/hg "HD-HG-" 4 X)
754 '(=hanyo-denshi/ip "HD-IP-" 4 X)
755 '(=hanyo-denshi/jt "HD-JT-" 4 X)
756 '(=hanyo-denshi/ks "HD-KS-" 6 d)
757 '(=>>hanyo-denshi/ja "G-HD-JA-" 4 X)
758 '(=>>hanyo-denshi/jb "G-HD-JB-" 4 X)
759 '(=>>hanyo-denshi/jc "G-HD-JC-" 4 X)
760 '(=>>hanyo-denshi/jd "G-HD-JD-" 4 X)
761 '(=>>hanyo-denshi/ft "G-HD-FT-" 4 X)
762 '(=>>hanyo-denshi/ia "G-HD-IA-" 4 X)
763 '(=>>hanyo-denshi/ib "G-HD-IB-" 4 X)
764 '(=>>hanyo-denshi/hg "G-HD-HG-" 4 X)
765 '(=>>hanyo-denshi/ip "G-HD-IP-" 4 X)
766 '(=>>hanyo-denshi/jt "G-HD-JT-" 4 X)
767 '(=>>hanyo-denshi/ks "G-HD-KS-" 6 d)
768 '(==hanyo-denshi/ja "g2-HD-JA-" 4 X)
769 '(==hanyo-denshi/jb "g2-HD-JB-" 4 X)
770 '(==hanyo-denshi/jc "g2-HD-JC-" 4 X)
771 '(==hanyo-denshi/jd "g2-HD-JD-" 4 X)
772 '(==hanyo-denshi/ft "g2-HD-FT-" 4 X)
773 '(==hanyo-denshi/ia "g2-HD-IA-" 4 X)
774 '(==hanyo-denshi/ib "g2-HD-IB-" 4 X)
775 '(==hanyo-denshi/hg "g2-HD-HG-" 4 X)
776 '(==hanyo-denshi/ip "g2-HD-IP-" 4 X)
777 '(==hanyo-denshi/jt "g2-HD-JT-" 4 X)
778 '(==hanyo-denshi/ks "g2-HD-KS-" 6 d)
779 '(=cns11643-1 "C1-" 4 X)
780 '(=cns11643-2 "C2-" 4 X)
781 '(=cns11643-3 "C3-" 4 X)
782 '(=cns11643-4 "C4-" 4 X)
783 '(=cns11643-5 "C5-" 4 X)
784 '(=cns11643-6 "C6-" 4 X)
785 '(=cns11643-7 "C7-" 4 X)
786 '(=adobe-japan1-6 "AJ1-" 5 d)
787 '(=big5-cdp "CDP-" 4 X)
789 '(=gb12345 "G1-" 4 X)
790 '(=jis-x0208@1990 "J90-" 4 X)
791 '(=jis-x0212 "JSP-" 4 X)
793 '(=jis-x0208@1997 "J97-" 4 X)
794 '(=jis-x0208@1978 "J78-" 4 X)
795 '(=jis-x0208@1983 "J83-" 4 X)
796 '(=ruimoku-v6 "RUI6-" 4 X)
797 '(=zinbun-oracle "ZOB-" 4 d)
798 '(=jef-china3 "JC3-" 4 X)
799 '(=ucs@unicode "UU+" 4 X)
800 '(=ucs@JP/hanazono "hanaJU+" 4 X)
801 '(=daikanwa "M-" 5 d)
802 '(==cns11643-1 "R-C1-" 4 X)
803 '(==cns11643-2 "R-C2-" 4 X)
804 '(==cns11643-3 "R-C3-" 4 X)
805 '(==cns11643-4 "R-C4-" 4 X)
806 '(==cns11643-5 "R-C5-" 4 X)
807 '(==cns11643-6 "R-C6-" 4 X)
808 '(==cns11643-7 "R-C7-" 4 X)
809 coded-charset-entity-reference-alist)))
810 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
812 (goto-char (point-min))
813 (while (re-search-forward "&CB\\([0-9]+\\);" nil t)
814 (setq code (string-to-int (match-string 1)))
816 (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
819 chise-wiki-bitmap-glyphs-url
821 www-format-char-img-style)
824 (goto-char (point-min))
825 (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)
826 (setq plane (match-string 2)
827 code (string-to-int (match-string 3) 16))
829 (format "<img alt=\"J%s-%04X\" src=\"%s/JIS-%s/%02d-%02d.gif\"
832 chise-wiki-bitmap-glyphs-url
835 (- (logand code 255) 32)
836 www-format-char-img-style)
839 (goto-char (point-min))
840 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?J0-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
841 (setq code (string-to-int (match-string 2) 16))
843 (format "<img alt=\"J0-%04X\" src=\"%s/JIS-90/%02d-%02d.gif\"
846 chise-wiki-bitmap-glyphs-url
848 (- (logand code 255) 32)
849 www-format-char-img-style)
852 (goto-char (point-min))
853 (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)
854 (setq plane (match-string 2)
855 code (string-to-int (match-string 3) 16))
857 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%02d%02d.png\"
860 chise-wiki-bitmap-glyphs-url
863 (- (logand code 255) 32)
864 www-format-char-img-style)
867 (goto-char (point-min))
868 (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)
869 (setq plane (match-string 2)
870 code (string-to-int (match-string 3) 16))
872 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%04X.png\"
875 chise-wiki-bitmap-glyphs-url
877 www-format-char-img-style)
880 (goto-char (point-min))
881 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?HD-KS-\\([0-9]+\\);" nil t)
882 (setq code (string-to-int (match-string 2)))
884 (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/KS%06d.png\"
885 style=\"vertical-align:middle\">"
887 chise-wiki-bitmap-glyphs-url
889 www-format-char-img-style)
892 (goto-char (point-min))
893 (while (re-search-forward "&G\\([01]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
894 (setq plane (string-to-int (match-string 1))
895 code (string-to-int (match-string 2) 16))
897 (format "<img alt=\"GB%d-%04X\" src=\"%s/GB%d/%02d-%02d.gif\"
900 chise-wiki-bitmap-glyphs-url
903 (- (logand code 255) 32)
904 www-format-char-img-style)
907 (goto-char (point-min))
908 (while (re-search-forward "&\\(R-\\)?C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
909 (setq plane (string-to-int (match-string 2))
910 code (string-to-int (match-string 3) 16))
912 (format "<img alt=\"CNS%d-%04X\" src=\"%s/CNS%d/%04X.gif\"
915 chise-wiki-bitmap-glyphs-url
917 www-format-char-img-style)
920 (goto-char (point-min))
921 (while (re-search-forward "&\\(R-\\)?JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
922 (setq code (string-to-int (match-string 2) 16))
924 (format "<img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">"
928 (goto-char (point-min))
929 (while (re-search-forward "&\\(A-\\)?ZOB-\\([0-9]+\\);" nil t)
930 (setq code (string-to-int (match-string 2)))
932 (format "<img alt=\"ZOB-%04d\" src=\"%s/ZOB-1968/%04d.png\"
933 style=\"vertical-align:middle\">"
935 chise-wiki-bitmap-glyphs-url
937 www-format-char-img-style)
940 (goto-char (point-min))
941 (while (re-search-forward "&HNG\\([0-9]+\\)-\\([0-9][0-9][0-9][0-9]\\)\\([0-9]\\);" nil t)
942 (setq plane (match-string 1)
943 code (string-to-int (match-string 2))
944 subcode (string-to-int (match-string 3)))
948 (char-to-string (decode-char 'ascii (+ 96 subcode)))))
951 "<img alt=\"HNG%s-%04d%s\" src=\"%s/%s/%04d%s.png\"
952 style=\"vertical-align:middle; width: 48px; height: 48px\">"
954 chise-wiki-hng-bitmap-glyphs-url
956 www-format-char-img-style)
959 (goto-char (point-min))
960 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?AJ1-\\([0-9]+\\);" nil t)
961 (setq code (string-to-int (match-string 2)))
963 (format "<img alt=\"AJ1-%05d\" src=\"%s/IVD/AdobeJapan1/CID+%d.png\"
964 style=\"vertical-align:middle\">"
966 chise-wiki-bitmap-glyphs-url
968 www-format-char-img-style)
971 (goto-char (point-min))
972 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?MJ\\([0-9]+\\);" nil t)
973 (setq code (string-to-int (match-string 2)))
975 (format "<img alt=\"MJ%06d\" src=\"http://mojikiban.ipa.go.jp/search/MJ%06d\"
976 style=\"vertical-align:middle; width: 48px; height: 48px\">"
979 www-format-char-img-style)
982 (goto-char (point-min))
983 (while (re-search-forward "&\\(G-\\|R-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
984 (setq code (string-to-int (match-string 2)))
986 (format "<img alt=\"GT-%05d\" src=\"%s?char=GT-%05d\"
989 chise-wiki-glyph-cgi-url
991 www-format-char-img-style)
994 (goto-char (point-min))
995 (while (re-search-forward "&\\(G-\\)?GT-K\\([0-9]+\\);" nil t)
996 (setq code (string-to-int (match-string 2)))
998 (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\"
1001 chise-wiki-glyph-cgi-url
1003 www-format-char-img-style)
1006 (goto-char (point-min))
1007 (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
1008 (setq code (string-to-int (match-string 1) 16))
1010 (format "<img alt=\"B-%04X\" src=\"%s?char=B-%04X\"
1013 chise-wiki-glyph-cgi-url
1015 www-format-char-img-style)
1018 (goto-char (point-min))
1019 (while (re-search-forward "&\\(G-\\|g2-\\|R-\\)?CDP-\\([0-9A-F]+\\);" nil t)
1020 (setq code (string-to-int (match-string 2) 16))
1022 (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
1025 chise-wiki-glyph-cgi-url
1027 www-format-char-img-style)
1030 (goto-char (point-min))
1031 (while (re-search-forward "&RUI6-\\([0-9A-F]+\\);" nil t)
1032 (setq code (string-to-int (match-string 1) 16))
1034 (format "<img alt=\"RUI6-%04X\" src=\"%s?char=RUI6-%04X\"
1035 style=\"vertical-align:middle\">"
1037 chise-wiki-glyph-cgi-url
1039 www-format-char-img-style)
1042 (goto-char (point-min))
1043 (while (re-search-forward "&hanaJU\\+\\([0-9A-F]+\\);" nil t)
1044 (setq code (string-to-int (match-string 1) 16))
1046 (format "<img alt=\"hanaJU+%04X\" src=\"%s?char=hana-JU+%04X\"
1047 style=\"vertical-align:middle\">"
1049 chise-wiki-glyph-cgi-url
1051 www-format-char-img-style)
1054 (goto-char (point-min))
1055 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\|R-\\)?\\(UU\\+\\|U-\\)\\([0-9A-F]+\\);" nil t)
1056 (setq code (string-to-int (match-string 3) 16))
1058 (format "<img alt=\"UU+%04X\" src=\"http://www.unicode.org/cgi-bin/refglyph?24-%04X\"
1059 style=\"vertical-align:middle\">"
1062 www-format-char-img-style)
1065 (goto-char (point-min))
1066 (while (re-search-forward "&MCS-\\([0-9A-F]+\\);" nil t)
1067 (setq code (string-to-int (match-string 1) 16))
1068 (setq start (match-beginning 0)
1070 (setq char (decode-char 'system-char-id code))
1072 ((and (setq variants
1073 (or (www-get-feature-value char '->subsumptive)
1074 (www-get-feature-value char '->denotational)))
1076 (while (and variants
1077 (setq ret (www-format-encode-string
1078 (char-to-string (car variants))))
1079 (string-match "&MCS-\\([0-9A-F]+\\);" ret))
1080 (setq variants (cdr variants)))
1082 (unless (string-match "&MCS-\\([0-9A-F]+\\);" ret)
1084 (delete-region start end)
1087 ((setq ret (or (www-get-feature-value char 'ideographic-combination)
1088 (www-get-feature-value char 'ideographic-structure)))
1093 (if (characterp (setq rret (find-char ch)))
1096 (www-format-encode-string
1097 (char-to-string ch) without-tags)
1098 (www-format-encode-string
1099 (format "%S" ch) without-tags)))
1103 (delete-region start end)
1107 ;; (goto-char (point-min))
1108 ;; (while (search-forward ">-" nil t)
1109 ;; (replace-match "&GT-" t 'literal))
1112 (defun www-html-display-text (text)
1116 (goto-char (point-min))
1117 (while (search-forward "<" nil t)
1118 (replace-match "<" nil t))
1119 (goto-char (point-min))
1120 (while (search-forward ">" nil t)
1121 (replace-match ">" nil t))
1122 (goto-char (point-min))
1123 (while (re-search-forward "\\[\\[\\([^]|[]+\\)|\\([^][]+\\)\\]\\]" nil t)
1125 (format "<a href=\"%s\">%s</a>"
1129 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
1130 (goto-char (point-min))
1131 (while (search-forward ">-" nil t)
1132 (replace-match "&GT-" nil t))
1135 (defun www-html-display-paragraph (text)
1137 (www-html-display-text text)
1144 (defvar coded-charset-GlyphWiki-id-alist
1145 '((=ucs "u" 4 x nil)
1146 (=adobe-japan1-0 "aj1-" 5 d nil)
1147 (=adobe-japan1-1 "aj1-" 5 d nil)
1148 (=adobe-japan1-2 "aj1-" 5 d nil)
1149 (=adobe-japan1-3 "aj1-" 5 d nil)
1150 (=adobe-japan1-4 "aj1-" 5 d nil)
1151 (=adobe-japan1-5 "aj1-" 5 d nil)
1152 (=adobe-japan1-6 "aj1-" 5 d nil)
1153 (==adobe-japan1-0 "aj1-" 5 d nil)
1154 (==adobe-japan1-1 "aj1-" 5 d nil)
1155 (==adobe-japan1-2 "aj1-" 5 d nil)
1156 (==adobe-japan1-3 "aj1-" 5 d nil)
1157 (==adobe-japan1-4 "aj1-" 5 d nil)
1158 (==adobe-japan1-5 "aj1-" 5 d nil)
1159 (==adobe-japan1-6 "aj1-" 5 d nil)
1160 (===adobe-japan1-0 "aj1-" 5 d nil)
1161 (===adobe-japan1-1 "aj1-" 5 d nil)
1162 (===adobe-japan1-2 "aj1-" 5 d nil)
1163 (===adobe-japan1-3 "aj1-" 5 d nil)
1164 (===adobe-japan1-4 "aj1-" 5 d nil)
1165 (===adobe-japan1-5 "aj1-" 5 d nil)
1166 (===adobe-japan1-6 "aj1-" 5 d nil)
1167 (=decomposition@cid)
1168 (=decomposition@hanyo-denshi)
1169 (=hanyo-denshi/ks "koseki-" 6 d nil)
1170 (=>>hanyo-denshi/ks "koseki-" 6 d nil)
1171 (=ucs@jis "u" 4 x nil)
1172 (==ucs@jis "u" 4 x nil)
1173 (===ucs@jis "u" 4 x nil)
1174 (=ucs@cns "u" 4 x "-t")
1175 (==ucs@cns "u" 4 x "-t")
1176 (=jis-x0212 "jsp-" 4 x nil)
1177 (=jis-x0213-1@2000 "jx1-2000-" 4 x nil)
1178 (=jis-x0213-1@2004 "jx1-2004-" 4 x nil)
1179 (=jis-x0213-2 "jx2-" 4 x nil)
1181 (=daikanwa "dkw-" 5 d nil)
1182 (==daikanwa "dkw-" 5 d nil)
1183 (===daikanwa "dkw-" 5 d nil)
1184 (=gt-k "gt-k" 5 d nil)
1185 (=jef-china3 "jc3-" 4 x nil)
1186 (=big5 "b-" 4 x nil)
1187 (=ucs@ks "u" 4 x "-k")
1188 (==ucs@ks "u" 4 x "-k")
1189 (===ucs@ks "u" 4 x "-k")
1190 (=ks-x1001 "k0-" 4 x nil)
1191 (=jis-x0208@1978/1pr "j78-" 4 x nil)
1192 (=jis-x0208@1978/-4pr "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 (=+>jis-x0208@1978 "j78-" 4 x nil)
1197 (=ucs@JP "u" 4 x nil)
1198 (=ucs@gb "u" 4 x "-g")
1199 (=ucs@iso "u" 4 x "-u")
1200 (=ucs@unicode "u" 4 x "-us")
1201 (=big5-cdp "cdp-" 4 x nil)
1202 (=>>big5-cdp "cdp-" 4 x nil)
1203 (=cns11643-1 "c1-" 4 x nil)
1204 (=cns11643-2 "c2-" 4 x nil)
1205 (=cns11643-3 "c3-" 4 x nil)
1206 (=cns11643-4 "c4-" 4 x nil)
1207 (=cns11643-5 "c5-" 4 x nil)
1208 (=cns11643-6 "c6-" 4 x nil)
1209 (=cns11643-7 "c7-" 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 "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@1990 "j90-" 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 (=+>jis-x0208@1983 "j83-" 4 x nil)
1222 (=cbeta "cb" 5 d nil)
1223 (=>>daikanwa "dkw-" 5 d nil)
1226 (defun char-GlyphWiki-id (char)
1227 (let ((rest coded-charset-GlyphWiki-id-alist)
1230 (setq spec (pop rest))
1231 (null (setq ret (char-feature char (car spec))))))
1235 (mapconcat #'char-GlyphWiki-id ret "-"))
1236 (and (memq (car spec) '(=ucs@unicode '=ucs@iso))
1238 ((and (or (encode-char char '=jis-x0208@1990)
1239 (encode-char char '=jis-x0212)
1240 (encode-char char '=jis-x0213-1)
1241 (encode-char char '=jis-x0213-2))
1242 (setq code (encode-char char '=ucs@jis)))
1243 (format "u%04x" code)
1245 ((and (or (encode-char char '=gb2312)
1246 (encode-char char '=gb12345))
1247 (setq code (encode-char char '=ucs@gb)))
1248 (format "u%04x-g" code)
1250 ((and (or (encode-char char '=cns11643-1)
1251 (encode-char char '=cns11643-2)
1252 (encode-char char '=cns11643-3)
1253 (encode-char char '=cns11643-4)
1254 (encode-char char '=cns11643-5)
1255 (encode-char char '=cns11643-6)
1256 (encode-char char '=cns11643-7))
1257 (setq code (encode-char char '=ucs@cns)))
1258 (format "u%04x-t" code)
1260 ((and (encode-char char '=ks-x1001)
1261 (setq code (encode-char char '=ucs@ks)))
1262 (format "u%04x-k" code)
1264 (format (format "%s%%0%d%s%s"
1268 (or (nth 4 spec) ""))
1275 (provide 'cwiki-common)
1277 ;;; cwiki-common.el ends here