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 "^rep2\\." 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 "^gi\\." 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 (length (match-string 1 feature-name))
449 (est-uri-encode-feature-name-body
450 (substring feature-name (match-end 1))))
452 ((string-match "^=>\\([^=>]+\\)" feature-name)
454 (est-uri-encode-feature-name-body
455 (substring feature-name (match-beginning 1))))
457 ((string-match "^\\(=+\\)>" feature-name)
459 (length (match-string 1 feature-name))
460 (est-uri-encode-feature-name-body
461 (substring feature-name (match-end 0))))
463 ((string-match "^->" 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 (t (est-uri-encode-feature-name-body feature-name))))
475 (defun www-uri-make-feature-name-url (uri-genre uri-feature-name uri-object)
476 (if est-hide-cgi-mode
477 (format "../feature/%s&%s/%s"
478 uri-feature-name uri-genre uri-object)
479 (format "%s?feature=%s&%s=%s"
480 chise-wiki-view-url uri-feature-name uri-genre uri-object)))
482 (defun www-uri-decode-object (genre char-rep)
485 ((string-match (if est-hide-cgi-mode
486 "\\(%3D\\|=\\|%3A\\|:\\)"
487 "\\(%3A\\|:\\)") char-rep)
488 (setq ccs (substring char-rep 0 (match-beginning 0))
489 cpos (substring char-rep (match-end 0)))
490 (setq ccs (www-uri-decode-feature-name ccs))
491 (setq cpos (est-uri-decode-feature-name-body cpos))
493 ((string-match "^0x" cpos)
495 (string-to-number (substring cpos (match-end 0)) 16))
498 (setq cpos (car (read-from-string
500 cpos file-name-coding-system))))
502 (if (and (eq genre 'character)
504 (decode-char ccs cpos)
505 (concord-decode-object ccs cpos genre))
508 (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er))
510 ((eq genre 'character)
511 (when (= (length char-rep) 1)
515 (concord-decode-object
516 '=id (www-uri-decode-feature-name char-rep) 'feature)
519 (concord-decode-object
520 '=id (car (read-from-string char-rep)) genre)
523 (defun www-uri-encode-object (object)
524 (if (characterp object)
525 (if (encode-char object '=ucs)
528 (format "%%%02X" byte))
529 (encode-coding-string (char-to-string object) 'utf-8-mcs-er)
531 (let ((ccs-list '(; =ucs
532 =cns11643-1 =cns11643-2 =cns11643-3
533 =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7
535 =jis-x0208 =jis-x0208@1990
540 =jis-x0213-1@2000 =jis-x0213-1@2004
541 =jis-x0208@1983 =jis-x0208@1978
542 =zinbun-oracle =>zinbun-oracle
546 =>>>jis-x0208 =>>>jis-x0213-1 =>>>jis-x0213-2
547 =>>jis-x0208 =>>jis-x0213-1 =>>jis-x0213-2
549 =+>jis-x0208 =+>jis-x0213-1 =+>jis-x0213-2
552 =>jis-x0208 =>jis-x0213-1
554 =>ucs@iso =>ucs@unicode
555 =>ucs@jis =>ucs@cns =>ucs@ks
556 =>>ucs@iso =>>ucs@unicode
557 =>>ucs@jis =>>ucs@cns =>>ucs@ks
558 =>>>ucs@iso =>>>ucs@unicode
559 =>>>ucs@jis =>>>ucs@cns =>>>ucs@ks
565 (setq ccs (pop ccs-list))
566 (not (setq ret (encode-char object ccs 'defined-only)))))
568 (format (if est-hide-cgi-mode
571 (www-uri-encode-feature-name ccs)
573 ((and (setq ccs (car (split-char object)))
574 (setq ret (encode-char object ccs)))
575 (format (if est-hide-cgi-mode
578 (www-uri-encode-feature-name ccs)
581 (format (if est-hide-cgi-mode
582 "system-char-id=0x%X"
583 "system-char-id:0x%X")
584 (encode-char object 'system-char-id))
586 (format (if est-hide-cgi-mode
589 (est-uri-encode-feature-name-body
590 (format "%s" (concord-object-id object))))))
592 (defun est-format-object (object &optional readable)
593 (if (characterp object)
594 (char-to-string object)
595 (let ((ret (or (if readable
596 (or (concord-object-get object 'name)
597 (concord-object-get object '=name)
598 (concord-object-get object 'title)))
599 (concord-object-id object))))
602 (defun www-uri-make-object-url (object &optional uri-object)
603 (if est-hide-cgi-mode
606 (est-object-genre object)
608 (www-uri-encode-object object)))
611 (est-object-genre object)
613 (www-uri-encode-object object)))))
616 ;;; @ Feature name presentation
619 (defun www-format-feature-name-default (feature-name)
623 (symbol-name feature-name)
627 (defun www-format-feature-name-as-metadata (feature-name &optional lang)
628 (let ((str (symbol-name feature-name))
631 ((string-match "\\*[^*]+$" str)
632 (setq base (substring str 0 (match-beginning 0))
633 meta (substring str (match-beginning 0)))
634 (concat (www-format-feature-name* (intern base) lang)
637 (www-format-feature-name-default feature-name)
640 (defun www-format-feature-name-as-rel-to (feature-name)
641 (concat "\u2192" (substring (symbol-name feature-name) 2)))
643 (defun www-format-feature-name-as-rel-from (feature-name)
644 (concat "\u2190" (substring (symbol-name feature-name) 2)))
646 (defun www-format-feature-name-as-CCS (feature-name)
649 (symbol-name feature-name)
651 (dest (upcase (pop rest))))
652 (when (string-match "^=+>*" dest)
653 (setq dest (concat (substring dest 0 (match-end 0))
655 (substring dest (match-end 0)))))
659 (setq dest (concat dest " " (upcase (pop rest)))))
660 (if (string-match "^[0-9]+$" (car rest))
661 (concat dest "-" (car rest))
662 (concat dest " " (upcase (car rest))))
666 (defun www-format-feature-name* (feature-name &optional lang)
667 (let (name fn parent ret)
670 (char-feature-property
672 (intern (format "name@%s" lang))))
673 (char-feature-property
674 feature-name 'name)))
675 ((and (setq name (symbol-name feature-name))
676 (string-match "\\*" name))
677 (www-format-feature-name-as-metadata feature-name lang))
679 (setq fn feature-name)
680 (while (and (setq parent (char-feature-name-parent fn))
683 (char-feature-property
685 (intern (format "name@%s" lang))))
686 (char-feature-property
691 (concat ret (substring (symbol-name feature-name)
692 (length (symbol-name parent)))))
693 ((find-charset feature-name)
694 (www-format-feature-name-as-CCS feature-name))
695 ((string-match "^\\(->\\)" name)
696 (www-format-feature-name-as-rel-to feature-name))
697 ((string-match "^\\(<-\\)" name)
698 (www-format-feature-name-as-rel-from feature-name))
700 (www-format-feature-name-default feature-name)
704 (defun www-format-feature-name (feature-name &optional lang)
705 (www-format-encode-string
706 (www-format-feature-name* feature-name lang)))
712 (defvar www-format-char-img-style "vertical-align:bottom;")
714 (defun www-format-encode-string (string &optional without-tags as-body)
717 (let (plane code start end char variants ret rret)
719 (goto-char (point-min))
720 (while (search-forward "&" nil t)
721 (replace-match "&" nil t)))
722 (goto-char (point-min))
723 (while (search-forward "<" nil t)
724 (replace-match "<" nil t))
725 (goto-char (point-min))
726 (while (search-forward ">" nil t)
727 (replace-match ">" nil t))
729 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
730 (let ((coded-charset-entity-reference-alist
733 '(=hanyo-denshi/ja "HD-JA-" 4 X)
734 '(=hanyo-denshi/jb "HD-JB-" 4 X)
735 '(=hanyo-denshi/jc "HD-JC-" 4 X)
736 '(=hanyo-denshi/jd "HD-JD-" 4 X)
737 '(=hanyo-denshi/ft "HD-FT-" 4 X)
738 '(=hanyo-denshi/ia "HD-IA-" 4 X)
739 '(=hanyo-denshi/ib "HD-IB-" 4 X)
740 '(=hanyo-denshi/hg "HD-HG-" 4 X)
741 '(=hanyo-denshi/ip "HD-IP-" 4 X)
742 '(=hanyo-denshi/jt "HD-JT-" 4 X)
743 '(=hanyo-denshi/ks "HD-KS-" 6 d)
744 '(=cns11643-1 "C1-" 4 X)
745 '(=cns11643-2 "C2-" 4 X)
746 '(=cns11643-3 "C3-" 4 X)
747 '(=cns11643-4 "C4-" 4 X)
748 '(=cns11643-5 "C5-" 4 X)
749 '(=cns11643-6 "C6-" 4 X)
750 '(=cns11643-7 "C7-" 4 X)
751 '(=adobe-japan1-6 "AJ1-" 5 d)
752 '(=big5-cdp "CDP-" 4 X)
754 '(=gb12345 "G1-" 4 X)
755 '(=jis-x0208@1990 "J90-" 4 X)
756 '(=jis-x0212 "JSP-" 4 X)
758 '(=jis-x0208@1997 "J97-" 4 X)
759 '(=jis-x0208@1978 "J78-" 4 X)
760 '(=jis-x0208@1983 "J83-" 4 X)
761 '(=ruimoku-v6 "RUI6-" 4 X)
762 '(=zinbun-oracle "ZOB-" 4 d)
763 '(=jef-china3 "JC3-" 4 X)
764 '(=ucs@unicode "UU+" 4 X)
765 '(=ucs@JP/hanazono "hanaJU+" 4 X)
766 '(=daikanwa "M-" 5 d)
767 '(==cns11643-1 "R-C1-" 4 X)
768 '(==cns11643-2 "R-C2-" 4 X)
769 '(==cns11643-3 "R-C3-" 4 X)
770 '(==cns11643-4 "R-C4-" 4 X)
771 '(==cns11643-5 "R-C5-" 4 X)
772 '(==cns11643-6 "R-C6-" 4 X)
773 '(==cns11643-7 "R-C7-" 4 X)
774 coded-charset-entity-reference-alist)))
775 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
777 (goto-char (point-min))
778 (while (re-search-forward "&CB\\([0-9]+\\);" nil t)
779 (setq code (string-to-int (match-string 1)))
781 (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
784 chise-wiki-bitmap-glyphs-url
786 www-format-char-img-style)
789 (goto-char (point-min))
790 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?J\\(78\\|83\\|90\\|97\\|SP\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
791 (setq plane (match-string 2)
792 code (string-to-int (match-string 3) 16))
794 (format "<img alt=\"J%s-%04X\" src=\"%s/JIS-%s/%02d-%02d.gif\"
797 chise-wiki-bitmap-glyphs-url
800 (- (logand code 255) 32)
801 www-format-char-img-style)
804 (goto-char (point-min))
805 (while (re-search-forward "&\\(o-\\)?HD-\\(JA\\|JB\\|JC\\|JD\\|FT\\|IA\\|IB\\|HG\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
806 (setq plane (match-string 2)
807 code (string-to-int (match-string 3) 16))
809 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%02d%02d.png\"
812 chise-wiki-bitmap-glyphs-url
815 (- (logand code 255) 32)
816 www-format-char-img-style)
819 (goto-char (point-min))
820 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?HD-\\(IP\\|JT\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
821 (setq plane (match-string 2)
822 code (string-to-int (match-string 3) 16))
824 (format "<img alt=\"HD-%s-%04X\" src=\"%s/IVD/HanyoDenshi/%s%04X.png\"
827 chise-wiki-bitmap-glyphs-url
829 www-format-char-img-style)
832 (goto-char (point-min))
833 (while (re-search-forward "&\\(o-\\|G-\\|g2-\\)?HD-KS-\\([0-9]+\\);" nil t)
834 (setq code (string-to-int (match-string 2)))
836 (format "<img alt=\"HD-KS%06d\" src=\"%s/IVD/HanyoDenshi/KS%06d.png\"
837 style=\"vertical-align:middle\">"
839 chise-wiki-bitmap-glyphs-url
841 www-format-char-img-style)
844 (goto-char (point-min))
845 (while (re-search-forward "&G\\([01]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
846 (setq plane (string-to-int (match-string 1))
847 code (string-to-int (match-string 2) 16))
849 (format "<img alt=\"GB%d-%04X\" src=\"%s/GB%d/%02d-%02d.gif\"
852 chise-wiki-bitmap-glyphs-url
855 (- (logand code 255) 32)
856 www-format-char-img-style)
859 (goto-char (point-min))
860 (while (re-search-forward "&\\(R-\\)?C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
861 (setq plane (string-to-int (match-string 2))
862 code (string-to-int (match-string 3) 16))
864 (format "<img alt=\"CNS%d-%04X\" src=\"%s/CNS%d/%04X.gif\"
867 chise-wiki-bitmap-glyphs-url
869 www-format-char-img-style)
872 (goto-char (point-min))
873 (while (re-search-forward "&JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
874 (setq code (string-to-int (match-string 1) 16))
876 (format "<img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">"
880 (goto-char (point-min))
881 (while (re-search-forward "&\\(A-\\)?ZOB-\\([0-9]+\\);" nil t)
882 (setq code (string-to-int (match-string 2)))
884 (format "<img alt=\"ZOB-%04d\" src=\"%s/ZOB-1968/%04d.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 "&\\(o-\\|G-\\|g2-\\)?AJ1-\\([0-9]+\\);" nil t)
894 (setq code (string-to-int (match-string 2)))
896 (format "<img alt=\"AJ1-%05d\" src=\"%s/IVD/AdobeJapan1/CID+%d.png\"
897 style=\"vertical-align:middle\">"
899 chise-wiki-bitmap-glyphs-url
901 www-format-char-img-style)
904 (goto-char (point-min))
905 (while (re-search-forward "&\\(G-\\|R-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
906 (setq code (string-to-int (match-string 2)))
908 (format "<img alt=\"GT-%05d\" src=\"%s?char=GT-%05d\"
911 chise-wiki-glyph-cgi-url
913 www-format-char-img-style)
916 (goto-char (point-min))
917 (while (re-search-forward "&\\(G-\\)?GT-K\\([0-9]+\\);" nil t)
918 (setq code (string-to-int (match-string 2)))
920 (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\"
923 chise-wiki-glyph-cgi-url
925 www-format-char-img-style)
928 (goto-char (point-min))
929 (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
930 (setq code (string-to-int (match-string 1) 16))
932 (format "<img alt=\"B-%04X\" src=\"%s?char=B-%04X\"
935 chise-wiki-glyph-cgi-url
937 www-format-char-img-style)
940 (goto-char (point-min))
941 (while (re-search-forward "&CDP-\\([0-9A-F]+\\);" nil t)
942 (setq code (string-to-int (match-string 1) 16))
944 (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
947 chise-wiki-glyph-cgi-url
949 www-format-char-img-style)
952 (goto-char (point-min))
953 (while (re-search-forward "&RUI6-\\([0-9A-F]+\\);" nil t)
954 (setq code (string-to-int (match-string 1) 16))
956 (format "<img alt=\"RUI6-%04X\" src=\"%s?char=RUI6-%04X\"
957 style=\"vertical-align:middle\">"
959 chise-wiki-glyph-cgi-url
961 www-format-char-img-style)
964 (goto-char (point-min))
965 (while (re-search-forward "&hanaJU\\+\\([0-9A-F]+\\);" nil t)
966 (setq code (string-to-int (match-string 1) 16))
968 (format "<img alt=\"hanaJU+%04X\" src=\"%s?char=hana-JU+%04X\"
969 style=\"vertical-align:middle\">"
971 chise-wiki-glyph-cgi-url
973 www-format-char-img-style)
976 (goto-char (point-min))
977 (while (re-search-forward "&\\(A-\\|R-\\)?\\(UU\\+\\|U-\\)\\([0-9A-F]+\\);" nil t)
978 (setq code (string-to-int (match-string 3) 16))
980 (format "<img alt=\"UU+%04X\" src=\"http://www.unicode.org/cgi-bin/refglyph?24-%04X\"
981 style=\"vertical-align:middle\">"
984 www-format-char-img-style)
987 (goto-char (point-min))
988 (while (re-search-forward "&MCS-\\([0-9A-F]+\\);" nil t)
989 (setq code (string-to-int (match-string 1) 16))
990 (setq start (match-beginning 0)
992 (setq char (decode-char 'system-char-id code))
995 (or (www-get-feature-value char '->subsumptive)
996 (www-get-feature-value char '->denotational)))
999 (setq ret (www-format-encode-string
1000 (char-to-string (car variants))))
1001 (string-match "&MCS-\\([0-9A-F]+\\);" ret))
1002 (setq variants (cdr variants)))
1004 (unless (string-match "&MCS-\\([0-9A-F]+\\);" ret)
1006 (delete-region start end)
1009 ((setq ret (or (www-get-feature-value char 'ideographic-combination)
1010 (www-get-feature-value char 'ideographic-structure)))
1015 (if (characterp (setq rret (find-char ch)))
1018 (www-format-encode-string
1019 (char-to-string ch) without-tags)
1020 (www-format-encode-string
1021 (format "%S" ch) without-tags)))
1025 (delete-region start end)
1029 ;; (goto-char (point-min))
1030 ;; (while (search-forward ">-" nil t)
1031 ;; (replace-match "&GT-" t 'literal))
1034 (defun www-html-display-text (text)
1038 (goto-char (point-min))
1039 (while (search-forward "<" nil t)
1040 (replace-match "<" nil t))
1041 (goto-char (point-min))
1042 (while (search-forward ">" nil t)
1043 (replace-match ">" nil t))
1044 (goto-char (point-min))
1045 (while (re-search-forward "\\[\\[\\([^]|[]+\\)|\\([^][]+\\)\\]\\]" nil t)
1047 (format "<a href=\"%s\">%s</a>"
1051 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
1052 (goto-char (point-min))
1053 (while (search-forward ">-" nil t)
1054 (replace-match "&GT-" nil t))
1057 (defun www-html-display-paragraph (text)
1059 (www-html-display-text text)
1066 (defvar coded-charset-GlyphWiki-id-alist
1067 '((=ucs "u" 4 x nil)
1068 (=adobe-japan1-0 "aj1-" 5 d nil)
1069 (=adobe-japan1-1 "aj1-" 5 d nil)
1070 (=adobe-japan1-2 "aj1-" 5 d nil)
1071 (=adobe-japan1-3 "aj1-" 5 d nil)
1072 (=adobe-japan1-4 "aj1-" 5 d nil)
1073 (=adobe-japan1-5 "aj1-" 5 d nil)
1074 (=adobe-japan1-6 "aj1-" 5 d nil)
1075 (=decomposition@cid)
1076 (=decomposition@hanyo-denshi)
1077 (=hanyo-denshi/ks "koseki-" 6 d nil)
1078 (=>>hanyo-denshi/ks "koseki-" 6 d nil)
1079 (=ucs@jis "u" 4 x nil)
1080 (=ucs@cns "u" 4 x "-t")
1081 (=jis-x0212 "jsp-" 4 x nil)
1082 (=jis-x0213-1@2000 "jx1-2000-" 4 x nil)
1083 (=jis-x0213-1@2004 "jx1-2004-" 4 x nil)
1084 (=jis-x0213-2 "jx2-" 4 x nil)
1086 (=daikanwa "dkw-" 5 d nil)
1087 (=gt-k "gt-k" 5 d nil)
1088 (=jef-china3 "jc3-" 4 x nil)
1089 (=big5 "b-" 4 x nil)
1090 (=ucs@ks "u" 4 x "-k")
1091 (=ks-x1001 "k0-" 4 x nil)
1092 (=jis-x0208@1978/1pr "j78-" 4 x nil)
1093 (=jis-x0208@1978/-4pr "j78-" 4 x nil)
1094 (=jis-x0208@1978 "j78-" 4 x nil)
1095 (=>>>jis-x0208@1978 "j78-" 4 x nil)
1096 (=>>jis-x0208@1978 "j78-" 4 x nil)
1097 (=+>jis-x0208@1978 "j78-" 4 x nil)
1098 (=ucs@JP "u" 4 x nil)
1099 (=ucs@gb "u" 4 x "-g")
1100 (=ucs@iso "u" 4 x "-u")
1101 (=ucs@unicode "u" 4 x "-us")
1102 (=big5-cdp "cdp-" 4 x nil)
1103 (=>>big5-cdp "cdp-" 4 x nil)
1104 (=cns11643-1 "c1-" 4 x nil)
1105 (=cns11643-2 "c2-" 4 x nil)
1106 (=cns11643-3 "c3-" 4 x nil)
1107 (=cns11643-4 "c4-" 4 x nil)
1108 (=cns11643-5 "c5-" 4 x nil)
1109 (=cns11643-6 "c6-" 4 x nil)
1110 (=cns11643-7 "c7-" 4 x nil)
1111 (=jis-x0208 "j90-" 4 x nil)
1112 (=>>>jis-x0208 "j90-" 4 x nil)
1113 (=>>jis-x0208 "j90-" 4 x nil)
1114 (=+>jis-x0208 "j90-" 4 x nil)
1115 (=jis-x0208@1990 "j90-" 4 x nil)
1116 (=>>>jis-x0208@1990 "j90-" 4 x nil)
1117 (=>>jis-x0208@1990 "j90-" 4 x nil)
1118 (=+>jis-x0208@1990 "j90-" 4 x nil)
1119 (=jis-x0208@1983 "j83-" 4 x nil)
1120 (=>>>jis-x0208@1983 "j83-" 4 x nil)
1121 (=>>jis-x0208@1983 "j83-" 4 x nil)
1122 (=+>jis-x0208@1983 "j83-" 4 x nil)
1123 (=cbeta "cb" 5 d nil)
1124 (=>>daikanwa "dkw-" 5 d nil)
1127 (defun char-GlyphWiki-id (char)
1128 (let ((rest coded-charset-GlyphWiki-id-alist)
1131 (setq spec (pop rest))
1132 (null (setq ret (char-feature char (car spec))))))
1136 (mapconcat #'char-GlyphWiki-id ret "-"))
1137 (and (memq (car spec) '(=ucs@unicode '=ucs@iso))
1139 ((and (or (encode-char char '=jis-x0208@1990)
1140 (encode-char char '=jis-x0212)
1141 (encode-char char '=jis-x0213-1))
1142 (setq code (encode-char char '=ucs@jis)))
1143 (format "u%04x" code)
1145 ((and (or (encode-char char '=gb2312)
1146 (encode-char char '=gb12345))
1147 (setq code (encode-char char '=ucs@gb)))
1148 (format "u%04x-g" code)
1150 ((and (or (encode-char char '=cns11643-1)
1151 (encode-char char '=cns11643-2)
1152 (encode-char char '=cns11643-3)
1153 (encode-char char '=cns11643-4)
1154 (encode-char char '=cns11643-5)
1155 (encode-char char '=cns11643-6)
1156 (encode-char char '=cns11643-7))
1157 (setq code (encode-char char '=ucs@cns)))
1158 (format "u%04x-t" code)
1160 ((and (encode-char char '=ks-x1001)
1161 (setq code (encode-char char '=ucs@ks)))
1162 (format "u%04x-k" code)
1164 (format (format "%s%%0%d%s%s"
1168 (or (nth 4 spec) ""))
1175 (provide 'cwiki-common)
1177 ;;; cwiki-common.el ends here