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 (defvar est-hide-cgi-mode nil)
37 (defvar est-view-url-prefix "..")
38 (defvar chise-wiki-view-url "view.cgi")
39 (defvar chise-wiki-edit-url "edit.cgi")
41 (defvar chise-wiki-bitmap-glyphs-url
42 "http://www.chise.org/glyphs")
44 (defvar chise-wiki-glyph-cgi-url
45 "http://www.chise.org/chisewiki/glyph.cgi")
47 (defvar chise-wiki-displayed-features nil)
49 (defun decode-uri-string (string &optional coding-system)
50 (if (> (length string) 0)
54 (mapconcat (lambda (char)
57 (char-to-string char)))
59 (while (string-match "%\\([0-9A-F][0-9A-F]\\)" string i)
60 (setq dest (concat dest
61 (substring string i (match-beginning 0))
64 (string-to-int (match-string 1 string) 16))))
67 (concat dest (substring string i))
70 (defun www-feature-type (feature-name)
71 (or (char-feature-property feature-name 'type)
72 (let ((str (symbol-name feature-name)))
74 ((string-match "\\*note\\(@[^*]+\\)?$" str)
76 ((string-match "\\*sources\\(@[^*]+\\)?$" str)
78 ((string-match "\\*" str)
80 ((string-match "^\\(->\\|<-\\)" str)
82 ((string-match "^ideographic-structure\\(@\\|$\\)" str)
86 (defun www-feature-format (feature-name)
87 (or (char-feature-property feature-name 'format)
89 (setq fn feature-name)
90 (while (and (setq parent (char-feature-name-parent fn))
92 (char-feature-property
96 '((name) " : " (value))))
98 (defun www-feature-value-format (feature-name)
99 (or (char-feature-property feature-name 'value-presentation-format)
100 (char-feature-property feature-name 'value-format)
102 (setq fn feature-name)
103 (while (and (setq parent (char-feature-name-parent fn))
105 (or (char-feature-property
106 parent 'value-presentation-format)
107 (char-feature-property
108 parent 'value-format)))))
111 (let ((type (www-feature-type feature-name)))
112 (cond ((eq type 'relation)
114 ((eq type 'structure)
115 'space-separated-ids)
119 (if (find-charset feature-name)
120 (if (and (= (charset-dimension feature-name) 2)
121 (= (charset-chars feature-name) 94))
123 " (" (decimal) ") <" (ku-ten) "> " (prev-char) (next-char))
124 '("0x" (HEX) " (" (decimal) ") " (prev-char) (next-char))))
127 (defun char-feature-name-at-domain (feature-name domain)
129 (let ((name (symbol-name feature-name)))
131 ((string-match "@[^*]+$" name)
132 (intern (format "%s/%s" name domain))
135 (intern (format "%s@%s" name domain))
139 (defun char-feature-name-parent (feature-name)
140 (let ((name (symbol-name feature-name)))
141 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
142 (intern (substring name 0 (car (last (match-data) 2)))))))
144 (defun char-feature-name-domain (feature-name)
145 (let ((name (symbol-name feature-name)))
146 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
147 (intern (substring name (1+ (match-beginning 0)))))))
149 (defun char-feature-name-sans-versions (feature)
150 (let ((feature-name (symbol-name feature)))
151 (if (string-match "[@/]\\$rev=latest$" feature-name)
152 (intern (substring feature-name 0 (match-beginning 0)))
155 (defun est-object-genre (object)
156 (if (characterp object)
158 (concord-object-genre object)))
160 (defun www-get-feature-value (object feature)
161 (let ((latest-feature (char-feature-name-at-domain feature '$rev=latest)))
164 (mount-char-attribute-table latest-feature)
165 (or (char-feature object latest-feature)
166 (char-feature object feature))
169 (or (condition-case nil
170 (concord-object-get object latest-feature)
173 (concord-object-get object feature)
177 (defun get-previous-code-point (ccs code)
178 (let ((chars (charset-chars ccs))
179 (dim (charset-dimension ccs))
181 mask byte-min byte-max
204 (setq bytes (make-vector dim 0))
206 (aset bytes i (logand (lsh code (* i -8)) mask))
209 (while (and (< i dim)
211 (aset bytes i (1- (aref bytes i)))
212 (< (aref bytes i) byte-min)))
213 (aset bytes i byte-max)
216 (setq dest (aref bytes 0)
219 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
223 (defun get-next-code-point (ccs code)
224 (let ((chars (charset-chars ccs))
225 (dim (charset-dimension ccs))
227 mask byte-min byte-max
250 (setq bytes (make-vector dim 0))
252 (aset bytes i (logand (lsh code (* i -8)) mask))
255 (while (and (< i dim)
257 (aset bytes i (1+ (aref bytes i)))
258 (> (aref bytes i) byte-max)))
259 (aset bytes i byte-min)
262 (setq dest (aref bytes 0)
265 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
269 (defun find-previous-defined-code-point (ccs code)
270 (let ((i (get-previous-code-point ccs code))
273 ((eq ccs '=jis-x0208)
274 (setq ccs '=jis-x0208@1990))
275 ((eq ccs '=jis-x0213-1)
276 (setq ccs '=jis-x0213-1@2004)))
279 (null (setq char (decode-char ccs i
280 (unless (eq ccs '=ucs)
282 (setq i (get-previous-code-point ccs i)))
285 (defun find-next-defined-code-point (ccs code)
286 (let ((i (get-next-code-point ccs code))
288 (setq max (+ code 1000))
290 ((eq ccs '=jis-x0208)
291 (setq ccs '=jis-x0208@1990))
292 ((eq ccs '=jis-x0213-1)
293 (setq ccs '=jis-x0213-1@2004)))
296 (null (setq char (decode-char ccs i
297 (unless (eq ccs '=ucs)
299 (setq i (get-next-code-point ccs i)))
303 ;;; @ URI representation
306 (defun est-uri-decode-feature-name-body (uri-feature)
307 (let ((len (length uri-feature))
314 (if (eq (aref uri-feature i) ?\.)
315 (if (and (< (+ i 2) len)
316 (eq (aref uri-feature (+ i 2)) ?\.))
319 ((eq (setq ch (aref uri-feature (1+ i))) ?\.)
324 (substring uri-feature i (+ i 3))
330 (char-to-string (aref uri-feature i))
334 (defun est-uri-encode-feature-name-body (feature)
335 (mapconcat (lambda (c)
340 (t (char-to-string c))))
343 (defun www-uri-decode-feature-name (uri-feature)
345 (setq uri-feature (decode-uri-string uri-feature 'utf-8-mcs-er))
347 ((string-match "^from\\." uri-feature)
348 (intern (format "<-%s"
349 (est-uri-decode-feature-name-body
350 (substring uri-feature (match-end 0)))))
352 ((string-match "^to\\." uri-feature)
353 (intern (format "->%s"
354 (est-uri-decode-feature-name-body
355 (substring uri-feature (match-end 0)))))
357 ((string-match "^rep\\." uri-feature)
358 (intern (format "=%s"
359 (est-uri-decode-feature-name-body
360 (substring uri-feature (match-end 0)))))
362 ((string-match "^rep[2i]\\." uri-feature)
363 (intern (format "===%s"
364 (est-uri-decode-feature-name-body
365 (substring uri-feature (match-end 0)))))
367 ((string-match "^g\\." uri-feature)
368 (intern (format "=>>%s"
369 (est-uri-decode-feature-name-body
370 (substring uri-feature (match-end 0)))))
372 ((string-match "^g[i2]\\." uri-feature)
373 (intern (format "==%s"
374 (est-uri-decode-feature-name-body
375 (substring uri-feature (match-end 0)))))
377 ((string-match "^gi\\([0-9]+\\)\\." uri-feature)
378 (intern (format "=>>%s%s"
379 (make-string (string-to-int
380 (match-string 1 uri-feature))
382 (est-uri-decode-feature-name-body
383 (substring uri-feature (match-end 0)))))
385 ((string-match "^o\\." uri-feature)
386 (intern (format "=+>%s"
387 (est-uri-decode-feature-name-body
388 (substring uri-feature (match-end 0)))))
390 ((string-match "^a\\." uri-feature)
391 (intern (format "=>%s"
392 (est-uri-decode-feature-name-body
393 (substring uri-feature (match-end 0)))))
395 ((string-match "^a\\([0-9]+\\)\\." uri-feature)
396 (intern (format "%s>%s"
397 (make-string (string-to-int
398 (match-string 1 uri-feature))
400 (est-uri-decode-feature-name-body
401 (substring uri-feature (match-end 0)))))
403 ((and (setq uri-feature (est-uri-decode-feature-name-body uri-feature))
404 (setq feature (intern (format "=>%s" uri-feature)))
405 (find-charset feature))
407 ((and (setq feature (intern (format "=>>%s" uri-feature)))
408 (find-charset feature))
410 ((and (setq feature (intern (format "=>>>%s" uri-feature)))
411 (find-charset feature))
413 ((and (setq feature (intern (format "=%s" uri-feature)))
414 (find-charset feature))
416 (t (intern uri-feature)))))
418 (defun www-uri-encode-feature-name (feature-name)
419 (setq feature-name (symbol-name feature-name))
421 ((string-match "^=\\+>\\([^=>]+\\)" feature-name)
423 (est-uri-encode-feature-name-body
424 (substring feature-name (match-beginning 1))))
426 ((string-match "^=\\([^=>]+\\)" feature-name)
428 (est-uri-encode-feature-name-body
429 (substring feature-name (match-beginning 1))))
431 ((string-match "^==\\([^=>]+\\)" feature-name)
433 (est-uri-encode-feature-name-body
434 (substring feature-name (match-beginning 1))))
436 ((string-match "^===\\([^=>]+\\)" feature-name)
438 (est-uri-encode-feature-name-body
439 (substring feature-name (match-beginning 1))))
441 ((string-match "^=>>\\([^=>]+\\)" feature-name)
443 (est-uri-encode-feature-name-body
444 (substring feature-name (match-beginning 1))))
446 ((string-match "^=>>>\\([^=>]+\\)" feature-name)
448 (est-uri-encode-feature-name-body
449 (substring feature-name (match-beginning 1))))
451 ((string-match "^=>>\\(>+\\)" feature-name)
453 (length (match-string 1 feature-name))
454 (est-uri-encode-feature-name-body
455 (substring feature-name (match-end 1))))
457 ((string-match "^=>\\([^=>]+\\)" feature-name)
459 (est-uri-encode-feature-name-body
460 (substring feature-name (match-beginning 1))))
462 ((string-match "^\\(=+\\)>" feature-name)
464 (length (match-string 1 feature-name))
465 (est-uri-encode-feature-name-body
466 (substring feature-name (match-end 0))))
468 ((string-match "^->" feature-name)
470 (est-uri-encode-feature-name-body
471 (substring feature-name (match-end 0))))
473 ((string-match "^<-" feature-name)
475 (est-uri-encode-feature-name-body
476 (substring feature-name (match-end 0))))
478 (t (est-uri-encode-feature-name-body feature-name))))
480 (defun www-uri-make-feature-name-url (uri-genre uri-feature-name uri-object)
481 (if est-hide-cgi-mode
482 (format "../feature/%s&%s/%s"
483 uri-feature-name uri-genre uri-object)
484 (format "%s?feature=%s&%s=%s"
485 chise-wiki-view-url uri-feature-name uri-genre uri-object)))
487 (defun www-uri-decode-object (genre char-rep)
490 ((string-match (if est-hide-cgi-mode
491 "\\(%3D\\|=\\|%3A\\|:\\)"
492 "\\(%3A\\|:\\)") char-rep)
493 (setq ccs (substring char-rep 0 (match-beginning 0))
494 cpos (substring char-rep (match-end 0)))
495 (setq ccs (www-uri-decode-feature-name ccs))
496 (setq cpos (est-uri-decode-feature-name-body cpos))
498 ((string-match "^0x" cpos)
500 (string-to-number (substring cpos (match-end 0)) 16))
503 (setq cpos (car (read-from-string
505 cpos file-name-coding-system))))
507 (if (and (eq genre 'character)
509 (decode-char ccs cpos)
510 (concord-decode-object ccs cpos genre))
513 (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er))
515 ((eq genre 'character)
516 (when (= (length char-rep) 1)
520 (concord-decode-object
521 '=id (www-uri-decode-feature-name char-rep) 'feature)
524 (concord-decode-object
525 '=id (car (read-from-string char-rep)) genre)
528 (defun www-uri-encode-object (object)
529 (if (characterp object)
530 (if (encode-char object '=ucs)
533 (format "%%%02X" byte))
534 (encode-coding-string (char-to-string object) 'utf-8-mcs-er)
536 (let ((ccs-list '(; =ucs
537 =cns11643-1 =cns11643-2 =cns11643-3
538 =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7
540 =jis-x0208 =jis-x0208@1990
545 =jis-x0213-1@2000 =jis-x0213-1@2004
546 =jis-x0208@1983 =jis-x0208@1978
547 =zinbun-oracle =>zinbun-oracle
551 =>>>jis-x0208 =>>>jis-x0213-1 =>>>jis-x0213-2
552 =>>jis-x0208 =>>jis-x0213-1 =>>jis-x0213-2
554 =+>jis-x0208 =+>jis-x0213-1 =+>jis-x0213-2
557 =>jis-x0208 =>jis-x0213-1
559 =>ucs@iso =>ucs@unicode
560 =>ucs@jis =>ucs@cns =>ucs@ks
561 =>>ucs@iso =>>ucs@unicode
562 =>>ucs@jis =>>ucs@cns =>>ucs@ks
563 =>>>ucs@iso =>>>ucs@unicode
564 =>>>ucs@jis =>>>ucs@cns =>>>ucs@ks
570 (setq ccs (pop ccs-list))
571 (not (setq ret (encode-char object ccs 'defined-only)))))
573 (format (if est-hide-cgi-mode
576 (www-uri-encode-feature-name ccs)
578 ((and (setq ccs (car (split-char object)))
579 (setq ret (encode-char object ccs)))
580 (format (if est-hide-cgi-mode
583 (www-uri-encode-feature-name ccs)
586 (format (if est-hide-cgi-mode
587 "system-char-id=0x%X"
588 "system-char-id:0x%X")
589 (encode-char object 'system-char-id))
591 (format (if est-hide-cgi-mode
594 (est-uri-encode-feature-name-body
595 (format "%s" (concord-object-id object))))))
597 (defun est-format-object (object &optional readable)
598 (if (characterp object)
599 (char-to-string object)
600 (let ((ret (or (if readable
601 (or (concord-object-get object 'name)
602 (concord-object-get object '=name)
603 (concord-object-get object 'title)))
604 (concord-object-id object))))
607 (defun www-uri-make-object-url (object &optional uri-object)
608 (if est-hide-cgi-mode
611 (est-object-genre object)
613 (www-uri-encode-object object)))
616 (est-object-genre object)
618 (www-uri-encode-object object)))))
621 ;;; @ Feature name presentation
624 (defun www-format-feature-name-default (feature-name)
628 (symbol-name feature-name)
632 (defun www-format-feature-name-as-metadata (feature-name &optional lang)
633 (let ((str (symbol-name feature-name))
636 ((string-match "\\*[^*]+$" str)
637 (setq base (substring str 0 (match-beginning 0))
638 meta (substring str (match-beginning 0)))
639 (concat (www-format-feature-name* (intern base) lang)
642 (www-format-feature-name-default feature-name)
645 (defun www-format-feature-name-as-rel-to (feature-name)
646 (concat "\u2192" (substring (symbol-name feature-name) 2)))
648 (defun www-format-feature-name-as-rel-from (feature-name)
649 (concat "\u2190" (substring (symbol-name feature-name) 2)))
651 (defun www-format-feature-name-as-CCS (feature-name)
654 (symbol-name feature-name)
656 (dest (upcase (pop rest))))
657 (when (string-match "^=+>*" dest)
658 (setq dest (concat (substring dest 0 (match-end 0))
660 (substring dest (match-end 0)))))
664 (setq dest (concat dest " " (upcase (pop rest)))))
665 (if (string-match "^[0-9]+$" (car rest))
666 (concat dest "-" (car rest))
667 (concat dest " " (upcase (car rest))))
671 (defun www-format-feature-name* (feature-name &optional lang)
672 (let (name fn parent ret)
675 (char-feature-property
677 (intern (format "name@%s" lang))))
678 (char-feature-property
679 feature-name 'name)))
680 ((and (setq name (symbol-name feature-name))
681 (string-match "\\*" name))
682 (www-format-feature-name-as-metadata feature-name lang))
684 (setq fn feature-name)
685 (while (and (setq parent (char-feature-name-parent fn))
688 (char-feature-property
690 (intern (format "name@%s" lang))))
691 (char-feature-property
696 (concat ret (substring (symbol-name feature-name)
697 (length (symbol-name parent)))))
698 ((find-charset feature-name)
699 (www-format-feature-name-as-CCS feature-name))
700 ((string-match "^\\(->\\)" name)
701 (www-format-feature-name-as-rel-to feature-name))
702 ((string-match "^\\(<-\\)" name)
703 (www-format-feature-name-as-rel-from feature-name))
705 (www-format-feature-name-default feature-name)
709 (defun www-format-feature-name (feature-name &optional lang)
710 (www-format-encode-string
711 (www-format-feature-name* feature-name lang)))
717 (defvar www-format-char-img-style "vertical-align:bottom;")
719 (defun www-format-encode-string (string &optional without-tags as-body)
722 (let (plane code start end char variants ret rret)
724 (goto-char (point-min))
725 (while (search-forward "&" nil t)
726 (replace-match "&" nil t)))
727 (goto-char (point-min))
728 (while (search-forward "<" nil t)
729 (replace-match "<" nil t))
730 (goto-char (point-min))
731 (while (search-forward ">" nil t)
732 (replace-match ">" nil t))
734 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
735 (let ((coded-charset-entity-reference-alist
738 '(=hanyo-denshi/ja "HD-JA-" 4 X)
739 '(=hanyo-denshi/jb "HD-JB-" 4 X)
740 '(=hanyo-denshi/jc "HD-JC-" 4 X)
741 '(=hanyo-denshi/jd "HD-JD-" 4 X)
742 '(=hanyo-denshi/ft "HD-FT-" 4 X)
743 '(=hanyo-denshi/ia "HD-IA-" 4 X)
744 '(=hanyo-denshi/ib "HD-IB-" 4 X)
745 '(=hanyo-denshi/hg "HD-HG-" 4 X)
746 '(=hanyo-denshi/ip "HD-IP-" 4 X)
747 '(=hanyo-denshi/jt "HD-JT-" 4 X)
748 '(=hanyo-denshi/ks "HD-KS-" 6 d)
749 '(=>>hanyo-denshi/ja "G-HD-JA-" 4 X)
750 '(=>>hanyo-denshi/jb "G-HD-JB-" 4 X)
751 '(=>>hanyo-denshi/jc "G-HD-JC-" 4 X)
752 '(=>>hanyo-denshi/jd "G-HD-JD-" 4 X)
753 '(=>>hanyo-denshi/ft "G-HD-FT-" 4 X)
754 '(=>>hanyo-denshi/ia "G-HD-IA-" 4 X)
755 '(=>>hanyo-denshi/ib "G-HD-IB-" 4 X)
756 '(=>>hanyo-denshi/hg "G-HD-HG-" 4 X)
757 '(=>>hanyo-denshi/ip "G-HD-IP-" 4 X)
758 '(=>>hanyo-denshi/jt "G-HD-JT-" 4 X)
759 '(=>>hanyo-denshi/ks "G-HD-KS-" 6 d)
760 '(==hanyo-denshi/ja "g2-HD-JA-" 4 X)
761 '(==hanyo-denshi/jb "g2-HD-JB-" 4 X)
762 '(==hanyo-denshi/jc "g2-HD-JC-" 4 X)
763 '(==hanyo-denshi/jd "g2-HD-JD-" 4 X)
764 '(==hanyo-denshi/ft "g2-HD-FT-" 4 X)
765 '(==hanyo-denshi/ia "g2-HD-IA-" 4 X)
766 '(==hanyo-denshi/ib "g2-HD-IB-" 4 X)
767 '(==hanyo-denshi/hg "g2-HD-HG-" 4 X)
768 '(==hanyo-denshi/ip "g2-HD-IP-" 4 X)
769 '(==hanyo-denshi/jt "g2-HD-JT-" 4 X)
770 '(==hanyo-denshi/ks "g2-HD-KS-" 6 d)
771 '(=cns11643-1 "C1-" 4 X)
772 '(=cns11643-2 "C2-" 4 X)
773 '(=cns11643-3 "C3-" 4 X)
774 '(=cns11643-4 "C4-" 4 X)
775 '(=cns11643-5 "C5-" 4 X)
776 '(=cns11643-6 "C6-" 4 X)
777 '(=cns11643-7 "C7-" 4 X)
778 '(=adobe-japan1-6 "AJ1-" 5 d)
779 '(=big5-cdp "CDP-" 4 X)
781 '(=gb12345 "G1-" 4 X)
782 '(=jis-x0208@1990 "J90-" 4 X)
783 '(=jis-x0212 "JSP-" 4 X)
785 '(=jis-x0208@1997 "J97-" 4 X)
786 '(=jis-x0208@1978 "J78-" 4 X)
787 '(=jis-x0208@1983 "J83-" 4 X)
788 '(=ruimoku-v6 "RUI6-" 4 X)
789 '(=zinbun-oracle "ZOB-" 4 d)
790 '(=jef-china3 "JC3-" 4 X)
791 '(=ucs@unicode "UU+" 4 X)
792 '(=ucs@JP/hanazono "hanaJU+" 4 X)
793 '(=daikanwa "M-" 5 d)
794 '(==cns11643-1 "R-C1-" 4 X)
795 '(==cns11643-2 "R-C2-" 4 X)
796 '(==cns11643-3 "R-C3-" 4 X)
797 '(==cns11643-4 "R-C4-" 4 X)
798 '(==cns11643-5 "R-C5-" 4 X)
799 '(==cns11643-6 "R-C6-" 4 X)
800 '(==cns11643-7 "R-C7-" 4 X)
801 coded-charset-entity-reference-alist)))
802 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
804 (goto-char (point-min))
805 (while (re-search-forward "&CB\\([0-9]+\\);" nil t)
806 (setq code (string-to-int (match-string 1)))
808 (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
811 chise-wiki-bitmap-glyphs-url
813 www-format-char-img-style)
816 (goto-char (point-min))
817 (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)
818 (setq plane (match-string 2)
819 code (string-to-int (match-string 3) 16))
821 (format "<img alt=\"J%s-%04X\" src=\"%s/JIS-%s/%02d-%02d.gif\"
824 chise-wiki-bitmap-glyphs-url
827 (- (logand code 255) 32)
828 www-format-char-img-style)
831 (goto-char (point-min))
832 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?HD-\\(JA\\|JB\\|JC\\|JD\\|FT\\|IA\\|IB\\|HG\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
833 (setq plane (match-string 2)
834 code (string-to-int (match-string 3) 16))
836 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%02d%02d.png\"
839 chise-wiki-bitmap-glyphs-url
842 (- (logand code 255) 32)
843 www-format-char-img-style)
846 (goto-char (point-min))
847 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?HD-\\(IP\\|JT\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
848 (setq plane (match-string 2)
849 code (string-to-int (match-string 3) 16))
851 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%04X.png\"
854 chise-wiki-bitmap-glyphs-url
856 www-format-char-img-style)
859 (goto-char (point-min))
860 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?HD-KS-\\([0-9]+\\);" nil t)
861 (setq code (string-to-int (match-string 2)))
863 (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/KS%06d.png\"
864 style=\"vertical-align:middle\">"
866 chise-wiki-bitmap-glyphs-url
868 www-format-char-img-style)
871 (goto-char (point-min))
872 (while (re-search-forward "&G\\([01]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
873 (setq plane (string-to-int (match-string 1))
874 code (string-to-int (match-string 2) 16))
876 (format "<img alt=\"GB%d-%04X\" src=\"%s/GB%d/%02d-%02d.gif\"
879 chise-wiki-bitmap-glyphs-url
882 (- (logand code 255) 32)
883 www-format-char-img-style)
886 (goto-char (point-min))
887 (while (re-search-forward "&\\(R-\\)?C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
888 (setq plane (string-to-int (match-string 2))
889 code (string-to-int (match-string 3) 16))
891 (format "<img alt=\"CNS%d-%04X\" src=\"%s/CNS%d/%04X.gif\"
894 chise-wiki-bitmap-glyphs-url
896 www-format-char-img-style)
899 (goto-char (point-min))
900 (while (re-search-forward "&\\(R-\\)?JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
901 (setq code (string-to-int (match-string 2) 16))
903 (format "<img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">"
907 (goto-char (point-min))
908 (while (re-search-forward "&\\(A-\\)?ZOB-\\([0-9]+\\);" nil t)
909 (setq code (string-to-int (match-string 2)))
911 (format "<img alt=\"ZOB-%04d\" src=\"%s/ZOB-1968/%04d.png\"
912 style=\"vertical-align:middle\">"
914 chise-wiki-bitmap-glyphs-url
916 www-format-char-img-style)
919 (goto-char (point-min))
920 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\|R-\\)?AJ1-\\([0-9]+\\);" nil t)
921 (setq code (string-to-int (match-string 2)))
923 (format "<img alt=\"AJ1-%05d\" src=\"%s/IVD/AdobeJapan1/CID+%d.png\"
924 style=\"vertical-align:middle\">"
926 chise-wiki-bitmap-glyphs-url
928 www-format-char-img-style)
931 (goto-char (point-min))
932 (while (re-search-forward "&\\(G-\\|R-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
933 (setq code (string-to-int (match-string 2)))
935 (format "<img alt=\"GT-%05d\" src=\"%s?char=GT-%05d\"
938 chise-wiki-glyph-cgi-url
940 www-format-char-img-style)
943 (goto-char (point-min))
944 (while (re-search-forward "&\\(G-\\)?GT-K\\([0-9]+\\);" nil t)
945 (setq code (string-to-int (match-string 2)))
947 (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\"
950 chise-wiki-glyph-cgi-url
952 www-format-char-img-style)
955 (goto-char (point-min))
956 (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
957 (setq code (string-to-int (match-string 1) 16))
959 (format "<img alt=\"B-%04X\" src=\"%s?char=B-%04X\"
962 chise-wiki-glyph-cgi-url
964 www-format-char-img-style)
967 (goto-char (point-min))
968 (while (re-search-forward "&CDP-\\([0-9A-F]+\\);" nil t)
969 (setq code (string-to-int (match-string 1) 16))
971 (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
974 chise-wiki-glyph-cgi-url
976 www-format-char-img-style)
979 (goto-char (point-min))
980 (while (re-search-forward "&RUI6-\\([0-9A-F]+\\);" nil t)
981 (setq code (string-to-int (match-string 1) 16))
983 (format "<img alt=\"RUI6-%04X\" src=\"%s?char=RUI6-%04X\"
984 style=\"vertical-align:middle\">"
986 chise-wiki-glyph-cgi-url
988 www-format-char-img-style)
991 (goto-char (point-min))
992 (while (re-search-forward "&hanaJU\\+\\([0-9A-F]+\\);" nil t)
993 (setq code (string-to-int (match-string 1) 16))
995 (format "<img alt=\"hanaJU+%04X\" src=\"%s?char=hana-JU+%04X\"
996 style=\"vertical-align:middle\">"
998 chise-wiki-glyph-cgi-url
1000 www-format-char-img-style)
1003 (goto-char (point-min))
1004 (while (re-search-forward "&\\(A-\\|G-\\|g2-\\|R-\\)?\\(UU\\+\\|U-\\)\\([0-9A-F]+\\);" nil t)
1005 (setq code (string-to-int (match-string 3) 16))
1007 (format "<img alt=\"UU+%04X\" src=\"http://www.unicode.org/cgi-bin/refglyph?24-%04X\"
1008 style=\"vertical-align:middle\">"
1011 www-format-char-img-style)
1014 (goto-char (point-min))
1015 (while (re-search-forward "&MCS-\\([0-9A-F]+\\);" nil t)
1016 (setq code (string-to-int (match-string 1) 16))
1017 (setq start (match-beginning 0)
1019 (setq char (decode-char 'system-char-id code))
1021 ((and (setq variants
1022 (or (www-get-feature-value char '->subsumptive)
1023 (www-get-feature-value char '->denotational)))
1025 (while (and variants
1026 (setq ret (www-format-encode-string
1027 (char-to-string (car variants))))
1028 (string-match "&MCS-\\([0-9A-F]+\\);" ret))
1029 (setq variants (cdr variants)))
1031 (unless (string-match "&MCS-\\([0-9A-F]+\\);" ret)
1033 (delete-region start end)
1036 ((setq ret (or (www-get-feature-value char 'ideographic-combination)
1037 (www-get-feature-value char 'ideographic-structure)))
1042 (if (characterp (setq rret (find-char ch)))
1045 (www-format-encode-string
1046 (char-to-string ch) without-tags)
1047 (www-format-encode-string
1048 (format "%S" ch) without-tags)))
1052 (delete-region start end)
1056 ;; (goto-char (point-min))
1057 ;; (while (search-forward ">-" nil t)
1058 ;; (replace-match "&GT-" t 'literal))
1061 (defun www-html-display-text (text)
1065 (goto-char (point-min))
1066 (while (search-forward "<" nil t)
1067 (replace-match "<" nil t))
1068 (goto-char (point-min))
1069 (while (search-forward ">" nil t)
1070 (replace-match ">" nil t))
1071 (goto-char (point-min))
1072 (while (re-search-forward "\\[\\[\\([^]|[]+\\)|\\([^][]+\\)\\]\\]" nil t)
1074 (format "<a href=\"%s\">%s</a>"
1078 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
1079 (goto-char (point-min))
1080 (while (search-forward ">-" nil t)
1081 (replace-match "&GT-" nil t))
1084 (defun www-html-display-paragraph (text)
1086 (www-html-display-text text)
1093 (defvar coded-charset-GlyphWiki-id-alist
1094 '((=ucs "u" 4 x nil)
1095 (=adobe-japan1-0 "aj1-" 5 d nil)
1096 (=adobe-japan1-1 "aj1-" 5 d nil)
1097 (=adobe-japan1-2 "aj1-" 5 d nil)
1098 (=adobe-japan1-3 "aj1-" 5 d nil)
1099 (=adobe-japan1-4 "aj1-" 5 d nil)
1100 (=adobe-japan1-5 "aj1-" 5 d nil)
1101 (=adobe-japan1-6 "aj1-" 5 d nil)
1102 (==adobe-japan1-0 "aj1-" 5 d nil)
1103 (==adobe-japan1-1 "aj1-" 5 d nil)
1104 (==adobe-japan1-2 "aj1-" 5 d nil)
1105 (==adobe-japan1-3 "aj1-" 5 d nil)
1106 (==adobe-japan1-4 "aj1-" 5 d nil)
1107 (==adobe-japan1-5 "aj1-" 5 d nil)
1108 (==adobe-japan1-6 "aj1-" 5 d nil)
1109 (===adobe-japan1-0 "aj1-" 5 d nil)
1110 (===adobe-japan1-1 "aj1-" 5 d nil)
1111 (===adobe-japan1-2 "aj1-" 5 d nil)
1112 (===adobe-japan1-3 "aj1-" 5 d nil)
1113 (===adobe-japan1-4 "aj1-" 5 d nil)
1114 (===adobe-japan1-5 "aj1-" 5 d nil)
1115 (===adobe-japan1-6 "aj1-" 5 d nil)
1116 (=decomposition@cid)
1117 (=decomposition@hanyo-denshi)
1118 (=hanyo-denshi/ks "koseki-" 6 d nil)
1119 (=>>hanyo-denshi/ks "koseki-" 6 d nil)
1120 (=ucs@jis "u" 4 x nil)
1121 (==ucs@jis "u" 4 x nil)
1122 (===ucs@jis "u" 4 x nil)
1123 (=ucs@cns "u" 4 x "-t")
1124 (==ucs@cns "u" 4 x "-t")
1125 (=jis-x0212 "jsp-" 4 x nil)
1126 (=jis-x0213-1@2000 "jx1-2000-" 4 x nil)
1127 (=jis-x0213-1@2004 "jx1-2004-" 4 x nil)
1128 (=jis-x0213-2 "jx2-" 4 x nil)
1130 (=daikanwa "dkw-" 5 d nil)
1131 (==daikanwa "dkw-" 5 d nil)
1132 (===daikanwa "dkw-" 5 d nil)
1133 (=gt-k "gt-k" 5 d nil)
1134 (=jef-china3 "jc3-" 4 x nil)
1135 (=big5 "b-" 4 x nil)
1136 (=ucs@ks "u" 4 x "-k")
1137 (==ucs@ks "u" 4 x "-k")
1138 (===ucs@ks "u" 4 x "-k")
1139 (=ks-x1001 "k0-" 4 x nil)
1140 (=jis-x0208@1978/1pr "j78-" 4 x nil)
1141 (=jis-x0208@1978/-4pr "j78-" 4 x nil)
1142 (=jis-x0208@1978 "j78-" 4 x nil)
1143 (=>>>jis-x0208@1978 "j78-" 4 x nil)
1144 (=>>jis-x0208@1978 "j78-" 4 x nil)
1145 (=+>jis-x0208@1978 "j78-" 4 x nil)
1146 (=ucs@JP "u" 4 x nil)
1147 (=ucs@gb "u" 4 x "-g")
1148 (=ucs@iso "u" 4 x "-u")
1149 (=ucs@unicode "u" 4 x "-us")
1150 (=big5-cdp "cdp-" 4 x nil)
1151 (=>>big5-cdp "cdp-" 4 x nil)
1152 (=cns11643-1 "c1-" 4 x nil)
1153 (=cns11643-2 "c2-" 4 x nil)
1154 (=cns11643-3 "c3-" 4 x nil)
1155 (=cns11643-4 "c4-" 4 x nil)
1156 (=cns11643-5 "c5-" 4 x nil)
1157 (=cns11643-6 "c6-" 4 x nil)
1158 (=cns11643-7 "c7-" 4 x nil)
1159 (=jis-x0208 "j90-" 4 x nil)
1160 (=>>>jis-x0208 "j90-" 4 x nil)
1161 (=>>jis-x0208 "j90-" 4 x nil)
1162 (=+>jis-x0208 "j90-" 4 x nil)
1163 (=jis-x0208@1990 "j90-" 4 x nil)
1164 (=>>>jis-x0208@1990 "j90-" 4 x nil)
1165 (=>>jis-x0208@1990 "j90-" 4 x nil)
1166 (=+>jis-x0208@1990 "j90-" 4 x nil)
1167 (=jis-x0208@1983 "j83-" 4 x nil)
1168 (=>>>jis-x0208@1983 "j83-" 4 x nil)
1169 (=>>jis-x0208@1983 "j83-" 4 x nil)
1170 (=+>jis-x0208@1983 "j83-" 4 x nil)
1171 (=cbeta "cb" 5 d nil)
1172 (=>>daikanwa "dkw-" 5 d nil)
1175 (defun char-GlyphWiki-id (char)
1176 (let ((rest coded-charset-GlyphWiki-id-alist)
1179 (setq spec (pop rest))
1180 (null (setq ret (char-feature char (car spec))))))
1184 (mapconcat #'char-GlyphWiki-id ret "-"))
1185 (and (memq (car spec) '(=ucs@unicode '=ucs@iso))
1187 ((and (or (encode-char char '=jis-x0208@1990)
1188 (encode-char char '=jis-x0212)
1189 (encode-char char '=jis-x0213-1)
1190 (encode-char char '=jis-x0213-2))
1191 (setq code (encode-char char '=ucs@jis)))
1192 (format "u%04x" code)
1194 ((and (or (encode-char char '=gb2312)
1195 (encode-char char '=gb12345))
1196 (setq code (encode-char char '=ucs@gb)))
1197 (format "u%04x-g" code)
1199 ((and (or (encode-char char '=cns11643-1)
1200 (encode-char char '=cns11643-2)
1201 (encode-char char '=cns11643-3)
1202 (encode-char char '=cns11643-4)
1203 (encode-char char '=cns11643-5)
1204 (encode-char char '=cns11643-6)
1205 (encode-char char '=cns11643-7))
1206 (setq code (encode-char char '=ucs@cns)))
1207 (format "u%04x-t" code)
1209 ((and (encode-char char '=ks-x1001)
1210 (setq code (encode-char char '=ucs@ks)))
1211 (format "u%04x-k" code)
1213 (format (format "%s%%0%d%s%s"
1217 (or (nth 4 spec) ""))
1224 (provide 'cwiki-common)
1226 ;;; cwiki-common.el ends here