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 chise-wiki-view-url "view.cgi")
37 (defvar chise-wiki-edit-url "edit.cgi")
39 (defvar chise-wiki-bitmap-glyphs-url
40 "http://www.chise.org/glyphs")
42 (defvar chise-wiki-glyph-cgi-url
43 "http://www.chise.org/chisewiki/glyph.cgi")
45 (defvar chise-wiki-displayed-features nil)
47 (defun decode-uri-string (string &optional coding-system)
48 (if (> (length string) 0)
52 (mapconcat (lambda (char)
55 (char-to-string char)))
57 (while (string-match "%\\([0-9A-F][0-9A-F]\\)" string i)
58 (setq dest (concat dest
59 (substring string i (match-beginning 0))
62 (string-to-int (match-string 1 string) 16))))
65 (concat dest (substring string i))
68 (defun www-feature-type (feature-name)
69 (or (char-feature-property feature-name 'type)
70 (let ((str (symbol-name feature-name)))
72 ((string-match "\\*note\\(@[^*]+\\)?$" str)
74 ((string-match "\\*sources\\(@[^*]+\\)?$" str)
76 ((string-match "\\*" str)
78 ((string-match "^\\(->\\|<-\\)" str)
80 ((string-match "^ideographic-structure\\(@\\|$\\)" str)
84 (defun www-feature-format (feature-name)
85 (or (char-feature-property feature-name 'format)
87 (setq fn feature-name)
88 (while (and (setq parent (char-feature-name-parent fn))
90 (char-feature-property
94 '((name) " : " (value))))
96 (defun www-feature-value-format (feature-name)
97 (or (char-feature-property feature-name 'value-presentation-format)
98 (char-feature-property feature-name 'value-format)
100 (setq fn feature-name)
101 (while (and (setq parent (char-feature-name-parent fn))
103 (or (char-feature-property
104 parent 'value-presentation-format)
105 (char-feature-property
106 parent 'value-format)))))
109 (let ((type (www-feature-type feature-name)))
110 (cond ((eq type 'relation)
112 ((eq type 'structure)
113 'space-separated-ids)
117 (if (find-charset feature-name)
118 (if (and (= (charset-dimension feature-name) 2)
119 (= (charset-chars feature-name) 94))
121 " (" (decimal) ") <" (ku-ten) "> " (prev-char) (next-char))
122 '("0x" (HEX) " (" (decimal) ") " (prev-char) (next-char))))
125 (defun char-feature-name-at-domain (feature-name domain)
127 (let ((name (symbol-name feature-name)))
129 ((string-match "@[^*]+$" name)
130 (intern (format "%s/%s" name domain))
133 (intern (format "%s@%s" name domain))
137 (defun char-feature-name-parent (feature-name)
138 (let ((name (symbol-name feature-name)))
139 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
140 (intern (substring name 0 (car (last (match-data) 2)))))))
142 (defun char-feature-name-domain (feature-name)
143 (let ((name (symbol-name feature-name)))
144 (if (string-match "@[^@/*]+\\(/[^@/*]+\\)*$" name)
145 (intern (substring name (1+ (match-beginning 0)))))))
147 (defun char-feature-name-sans-versions (feature)
148 (let ((feature-name (symbol-name feature)))
149 (if (string-match "[@/]\\$rev=latest$" feature-name)
150 (intern (substring feature-name 0 (match-beginning 0)))
153 (defun est-object-genre (object)
154 (if (characterp object)
156 (concord-object-genre object)))
158 (defun www-get-feature-value (object feature)
159 (let ((latest-feature (char-feature-name-at-domain feature '$rev=latest)))
162 (mount-char-attribute-table latest-feature)
163 (or (char-feature object latest-feature)
164 (char-feature object feature))
167 (or (condition-case nil
168 (concord-object-get object latest-feature)
171 (concord-object-get object feature)
175 (defun get-previous-code-point (ccs code)
176 (let ((chars (charset-chars ccs))
177 (dim (charset-dimension ccs))
179 mask byte-min byte-max
202 (setq bytes (make-vector dim 0))
204 (aset bytes i (logand (lsh code (* i -8)) mask))
207 (while (and (< i dim)
209 (aset bytes i (1- (aref bytes i)))
210 (< (aref bytes i) byte-min)))
211 (aset bytes i byte-max)
214 (setq dest (aref bytes 0)
217 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
221 (defun get-next-code-point (ccs code)
222 (let ((chars (charset-chars ccs))
223 (dim (charset-dimension ccs))
225 mask byte-min byte-max
248 (setq bytes (make-vector dim 0))
250 (aset bytes i (logand (lsh code (* i -8)) mask))
253 (while (and (< i dim)
255 (aset bytes i (1+ (aref bytes i)))
256 (> (aref bytes i) byte-max)))
257 (aset bytes i byte-min)
260 (setq dest (aref bytes 0)
263 (setq dest (logior dest (lsh (aref bytes i) (* i 8)))
267 (defun find-previous-defined-code-point (ccs code)
268 (let ((i (get-previous-code-point ccs code))
271 ((eq ccs '=jis-x0208)
272 (setq ccs '=jis-x0208@1990))
273 ((eq ccs '=jis-x0213-1)
274 (setq ccs '=jis-x0213-1@2004)))
277 (null (setq char (decode-char ccs i
278 (unless (eq ccs '=ucs)
280 (setq i (get-previous-code-point ccs i)))
283 (defun find-next-defined-code-point (ccs code)
284 (let ((i (get-next-code-point ccs code))
286 (setq max (+ code 1000))
288 ((eq ccs '=jis-x0208)
289 (setq ccs '=jis-x0208@1990))
290 ((eq ccs '=jis-x0213-1)
291 (setq ccs '=jis-x0213-1@2004)))
294 (null (setq char (decode-char ccs i
295 (unless (eq ccs '=ucs)
297 (setq i (get-next-code-point ccs i)))
301 ;;; @ URI representation
304 (defun www-uri-decode-feature-name (uri-feature)
306 (setq uri-feature (decode-uri-string uri-feature 'utf-8-mcs-er))
308 ((string-match "^from\\." uri-feature)
309 (intern (format "<-%s" (substring uri-feature (match-end 0))))
311 ((string-match "^to\\." uri-feature)
312 (intern (format "->%s" (substring uri-feature (match-end 0))))
314 ((string-match "^rep\\." uri-feature)
315 (intern (format "=%s" (substring uri-feature (match-end 0))))
317 ((string-match "^g\\." uri-feature)
318 (intern (format "=>>%s" (substring uri-feature (match-end 0))))
320 ((string-match "^gi\\." uri-feature)
321 (intern (format "=>>>%s" (substring uri-feature (match-end 0))))
323 ((string-match "^gi\\([0-9]+\\)\\." uri-feature)
324 (intern (format "=>>%s%s"
325 (make-string (string-to-int
326 (match-string 1 uri-feature))
328 (substring uri-feature (match-end 0))))
330 ((string-match "^o\\." uri-feature)
331 (intern (format "=+>%s" (substring uri-feature (match-end 0))))
333 ((string-match "^a\\." uri-feature)
334 (intern (format "=>%s" (substring uri-feature (match-end 0))))
336 ((string-match "^a\\([0-9]+\\)\\." uri-feature)
337 (intern (format "%s>%s"
338 (make-string (string-to-int
339 (match-string 1 uri-feature))
341 (substring uri-feature (match-end 0))))
343 ((and (setq feature (intern (format "=>%s" uri-feature)))
344 (find-charset feature))
346 ((and (setq feature (intern (format "=>>%s" uri-feature)))
347 (find-charset feature))
349 ((and (setq feature (intern (format "=>>>%s" uri-feature)))
350 (find-charset feature))
352 ((and (setq feature (intern (format "=%s" uri-feature)))
353 (find-charset feature))
355 (t (intern uri-feature)))))
357 (defun www-uri-encode-feature-name (feature-name)
358 (setq feature-name (symbol-name feature-name))
360 ((string-match "^=\\+>\\([^=>]+\\)" feature-name)
361 (concat "o." (substring feature-name (match-beginning 1)))
363 ((string-match "^=\\([^=>]+\\)" feature-name)
364 (concat "rep." (substring feature-name (match-beginning 1)))
366 ((string-match "^=>>\\([^=>]+\\)" feature-name)
367 (concat "g." (substring feature-name (match-beginning 1)))
369 ((string-match "^=>>>\\([^=>]+\\)" feature-name)
370 (concat "gi." (substring feature-name (match-beginning 1)))
372 ((string-match "^=>>\\(>+\\)" feature-name)
374 (length (match-string 1 feature-name))
375 (substring feature-name (match-end 1)))
377 ((string-match "^=>\\([^=>]+\\)" feature-name)
378 (concat "a." (substring feature-name (match-beginning 1)))
380 ((string-match "^\\(=+\\)>" feature-name)
382 (length (match-string 1 feature-name))
383 (substring feature-name (match-end 0)))
385 ((string-match "^->" feature-name)
386 (concat "to." (substring feature-name (match-end 0)))
388 ((string-match "^<-" feature-name)
389 (concat "from." (substring feature-name (match-end 0)))
393 (defun www-uri-make-feature-name-url (uri-genre uri-feature-name uri-object)
394 (format "%s?feature=%s&%s=%s"
395 chise-wiki-view-url uri-feature-name uri-genre uri-object))
397 (defun www-uri-decode-object (genre char-rep)
400 ((string-match "\\(%3A\\|:\\)" char-rep)
401 (setq ccs (substring char-rep 0 (match-beginning 0))
402 cpos (substring char-rep (match-end 0)))
403 (setq ccs (www-uri-decode-feature-name ccs))
405 ((string-match "^0x" cpos)
407 (string-to-number (substring cpos (match-end 0)) 16))
410 (setq cpos (car (read-from-string
412 cpos file-name-coding-system))))
414 (if (and (eq genre 'character)
416 (decode-char ccs cpos)
417 (concord-decode-object ccs cpos genre))
420 (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er))
422 ((eq genre 'character)
423 (when (= (length char-rep) 1)
427 (concord-decode-object
428 '=id (www-uri-decode-feature-name char-rep) 'feature)
431 (concord-decode-object
432 '=id (car (read-from-string char-rep)) genre)
435 (defun www-uri-encode-object (object)
436 (if (characterp object)
437 (if (encode-char object '=ucs)
440 (format "%%%02X" byte))
441 (encode-coding-string (char-to-string object) 'utf-8-mcs-er)
443 (let ((ccs-list '(; =ucs
444 =cns11643-1 =cns11643-2 =cns11643-3
445 =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7
447 =jis-x0208 =jis-x0208@1990
452 =jis-x0213-1@2000 =jis-x0213-1@2004
453 =jis-x0208@1983 =jis-x0208@1978
454 =zinbun-oracle =>zinbun-oracle
458 =>>>jis-x0208 =>>>jis-x0213-1 =>>>jis-x0213-2
459 =>>jis-x0208 =>>jis-x0213-1 =>>jis-x0213-2
461 =+>jis-x0208 =+>jis-x0213-1 =+>jis-x0213-2
464 =>jis-x0208 =>jis-x0213-1
466 =>ucs@iso =>ucs@unicode
467 =>ucs@jis =>ucs@cns =>ucs@ks
468 =>>ucs@iso =>>ucs@unicode
469 =>>ucs@jis =>>ucs@cns =>>ucs@ks
470 =>>>ucs@iso =>>>ucs@unicode
471 =>>>ucs@jis =>>>ucs@cns =>>>ucs@ks
477 (setq ccs (pop ccs-list))
478 (not (setq ret (encode-char object ccs 'defined-only)))))
481 (www-uri-encode-feature-name ccs)
483 ((and (setq ccs (car (split-char object)))
484 (setq ret (encode-char object ccs)))
486 (www-uri-encode-feature-name ccs)
489 (format "system-char-id:0x%X"
490 (encode-char object 'system-char-id))
492 (format "rep.id:%s" (concord-object-id object))))
494 (defun est-format-object (object &optional readable)
495 (if (characterp object)
496 (char-to-string object)
497 (let ((ret (or (if readable
498 (or (concord-object-get object 'name)
499 (concord-object-get object '=name)
500 (concord-object-get object 'title)))
501 (concord-object-id object))))
504 (defun www-uri-make-object-url (object &optional uri-object)
507 (est-object-genre object)
509 (www-uri-encode-object object))))
512 ;;; @ Feature name presentation
515 (defun www-format-feature-name-default (feature-name)
519 (symbol-name feature-name)
523 (defun www-format-feature-name-as-metadata (feature-name &optional lang)
524 (let ((str (symbol-name feature-name))
527 ((string-match "\\*[^*]+$" str)
528 (setq base (substring str 0 (match-beginning 0))
529 meta (substring str (match-beginning 0)))
530 (concat (www-format-feature-name* (intern base) lang)
533 (www-format-feature-name-default feature-name)
536 (defun www-format-feature-name-as-rel-to (feature-name)
537 (concat "\u2192" (substring (symbol-name feature-name) 2)))
539 (defun www-format-feature-name-as-rel-from (feature-name)
540 (concat "\u2190" (substring (symbol-name feature-name) 2)))
542 (defun www-format-feature-name-as-CCS (feature-name)
545 (symbol-name feature-name)
547 (dest (upcase (pop rest))))
548 (when (string-match "^=+>*" dest)
549 (setq dest (concat (substring dest 0 (match-end 0))
551 (substring dest (match-end 0)))))
555 (setq dest (concat dest " " (upcase (pop rest)))))
556 (if (string-match "^[0-9]+$" (car rest))
557 (concat dest "-" (car rest))
558 (concat dest " " (upcase (car rest))))
562 (defun www-format-feature-name* (feature-name &optional lang)
563 (let (name fn parent ret)
566 (char-feature-property
568 (intern (format "name@%s" lang))))
569 (char-feature-property
570 feature-name 'name)))
571 ((and (setq name (symbol-name feature-name))
572 (string-match "\\*" name))
573 (www-format-feature-name-as-metadata feature-name lang))
575 (setq fn feature-name)
576 (while (and (setq parent (char-feature-name-parent fn))
579 (char-feature-property
581 (intern (format "name@%s" lang))))
582 (char-feature-property
587 (concat ret (substring (symbol-name feature-name)
588 (length (symbol-name parent)))))
589 ((find-charset feature-name)
590 (www-format-feature-name-as-CCS feature-name))
591 ((string-match "^\\(->\\)" name)
592 (www-format-feature-name-as-rel-to feature-name))
593 ((string-match "^\\(<-\\)" name)
594 (www-format-feature-name-as-rel-from feature-name))
596 (www-format-feature-name-default feature-name)
600 (defun www-format-feature-name (feature-name &optional lang)
601 (www-format-encode-string
602 (www-format-feature-name* feature-name lang)))
608 (defvar www-format-char-img-style "vertical-align:bottom;")
610 (defun www-format-encode-string (string &optional without-tags as-body)
613 (let (plane code start end char variants ret rret)
615 (goto-char (point-min))
616 (while (search-forward "&" nil t)
617 (replace-match "&" nil t)))
618 (goto-char (point-min))
619 (while (search-forward "<" nil t)
620 (replace-match "<" nil t))
621 (goto-char (point-min))
622 (while (search-forward ">" nil t)
623 (replace-match ">" nil t))
625 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
626 (let ((coded-charset-entity-reference-alist
629 '(=cns11643-1 "C1-" 4 X)
630 '(=cns11643-2 "C2-" 4 X)
631 '(=cns11643-3 "C3-" 4 X)
632 '(=cns11643-4 "C4-" 4 X)
633 '(=cns11643-5 "C5-" 4 X)
634 '(=cns11643-6 "C6-" 4 X)
635 '(=cns11643-7 "C7-" 4 X)
637 '(=gb12345 "G1-" 4 X)
638 '(=jis-x0208@1990 "J90-" 4 X)
639 '(=jis-x0212 "JSP-" 4 X)
641 '(=jis-x0208@1997 "J97-" 4 X)
642 '(=jis-x0208@1978 "J78-" 4 X)
643 '(=jis-x0208@1983 "J83-" 4 X)
644 '(=ruimoku-v6 "RUI6-" 4 X)
645 '(=zinbun-oracle "ZOB-" 4 d)
646 '(=jef-china3 "JC3-" 4 X)
647 '(=daikanwa "M-" 5 d)
648 coded-charset-entity-reference-alist)))
649 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
651 (goto-char (point-min))
652 (while (re-search-forward "&CB\\([0-9]+\\);" nil t)
653 (setq code (string-to-int (match-string 1)))
655 (format "<img alt=\"CB%05d\" src=\"%s/cb-gaiji/%02d/CB%05d.gif\"
658 chise-wiki-bitmap-glyphs-url
660 www-format-char-img-style)
663 (goto-char (point-min))
664 (while (re-search-forward "&\\(o-\\)?J\\(78\\|83\\|90\\|97\\|SP\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
665 (setq plane (match-string 2)
666 code (string-to-int (match-string 3) 16))
668 (format "<img alt=\"J%s-%04X\" src=\"%s/JIS-%s/%02d-%02d.gif\"
671 chise-wiki-bitmap-glyphs-url
674 (- (logand code 255) 32)
675 www-format-char-img-style)
678 (goto-char (point-min))
679 (while (re-search-forward "&G\\([01]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
680 (setq plane (string-to-int (match-string 1))
681 code (string-to-int (match-string 2) 16))
683 (format "<img alt=\"GB%d-%04X\" src=\"%s/GB%d/%02d-%02d.gif\"
686 chise-wiki-bitmap-glyphs-url
689 (- (logand code 255) 32)
690 www-format-char-img-style)
693 (goto-char (point-min))
694 (while (re-search-forward "&C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
695 (setq plane (string-to-int (match-string 1))
696 code (string-to-int (match-string 2) 16))
698 (format "<img alt=\"CNS%d-%04X\" src=\"%s/CNS%d/%04X.gif\"
701 chise-wiki-bitmap-glyphs-url
703 www-format-char-img-style)
706 (goto-char (point-min))
707 (while (re-search-forward "&JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\);" nil t)
708 (setq code (string-to-int (match-string 1) 16))
710 (format "<img alt=\"JC3-%04X\" src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/%04x.gif\">"
714 (goto-char (point-min))
715 (while (re-search-forward "&\\(A-\\)?ZOB-\\([0-9]+\\);" nil t)
716 (setq code (string-to-int (match-string 2)))
718 (format "<img alt=\"ZOB-%04d\" src=\"%s/ZOB-1968/%04d.png\"
719 style=\"vertical-align:middle\">"
721 chise-wiki-bitmap-glyphs-url
723 www-format-char-img-style)
726 (goto-char (point-min))
727 (while (re-search-forward "&\\(G-\\|g2-\\)?GT-\\([0-9]+\\);" nil t)
728 (setq code (string-to-int (match-string 2)))
730 (format "<img alt=\"GT-%05d\" src=\"%s?char=GT-%05d\"
733 chise-wiki-glyph-cgi-url
735 www-format-char-img-style)
738 (goto-char (point-min))
739 (while (re-search-forward "&\\(G-\\)?GT-K\\([0-9]+\\);" nil t)
740 (setq code (string-to-int (match-string 2)))
742 (format "<img alt=\"GT-K%05d\" src=\"%s?char=GT-K%05d\"
745 chise-wiki-glyph-cgi-url
747 www-format-char-img-style)
750 (goto-char (point-min))
751 (while (re-search-forward "&B-\\([0-9A-F]+\\);" nil t)
752 (setq code (string-to-int (match-string 1) 16))
754 (format "<img alt=\"B-%04X\" src=\"%s?char=B-%04X\"
757 chise-wiki-glyph-cgi-url
759 www-format-char-img-style)
762 (goto-char (point-min))
763 (while (re-search-forward "&CDP-\\([0-9A-F]+\\);" nil t)
764 (setq code (string-to-int (match-string 1) 16))
766 (format "<img alt=\"CDP-%04X\" src=\"%s?char=CDP-%04X\"
769 chise-wiki-glyph-cgi-url
771 www-format-char-img-style)
774 (goto-char (point-min))
775 (while (re-search-forward "&RUI6-\\([0-9A-F]+\\);" nil t)
776 (setq code (string-to-int (match-string 1) 16))
778 (format "<img alt=\"RUI6-%04X\" src=\"%s?char=RUI6-%04X\"
779 style=\"vertical-align:middle\">"
781 chise-wiki-glyph-cgi-url
783 www-format-char-img-style)
786 (goto-char (point-min))
787 (while (re-search-forward "&\\(A-\\)?\\(UU\\+\\|U-\\)\\([0-9A-F]+\\);" nil t)
788 (setq code (string-to-int (match-string 3) 16))
790 (format "<img alt=\"UU+%04X\" src=\"http://www.unicode.org/cgi-bin/refglyph?24-%04X\"
791 style=\"vertical-align:middle\">"
794 www-format-char-img-style)
797 (goto-char (point-min))
798 (while (re-search-forward "&MCS-\\([0-9A-F]+\\);" nil t)
799 (setq code (string-to-int (match-string 1) 16))
800 (setq start (match-beginning 0)
802 (setq char (decode-char 'system-char-id code))
805 (or (www-get-feature-value char '->subsumptive)
806 (www-get-feature-value char '->denotational)))
809 (setq ret (www-format-encode-string
810 (char-to-string (car variants))))
811 (string-match "&MCS-\\([0-9A-F]+\\);" ret))
812 (setq variants (cdr variants)))
814 (unless (string-match "&MCS-\\([0-9A-F]+\\);" ret)
816 (delete-region start end)
819 ((setq ret (or (www-get-feature-value char 'ideographic-combination)
820 (www-get-feature-value char 'ideographic-structure)))
825 (if (characterp (setq rret (find-char ch)))
828 (www-format-encode-string
829 (char-to-string ch) without-tags)
830 (www-format-encode-string
831 (format "%S" ch) without-tags)))
835 (delete-region start end)
839 ;; (goto-char (point-min))
840 ;; (while (search-forward ">-" nil t)
841 ;; (replace-match "&GT-" t 'literal))
844 (defun www-html-display-text (text)
848 (goto-char (point-min))
849 (while (search-forward "<" nil t)
850 (replace-match "<" nil t))
851 (goto-char (point-min))
852 (while (search-forward ">" nil t)
853 (replace-match ">" nil t))
854 (goto-char (point-min))
855 (while (re-search-forward "\\[\\[\\([^]|[]+\\)|\\([^][]+\\)\\]\\]" nil t)
857 (format "<a href=\"%s\">%s</a>"
861 (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
862 (goto-char (point-min))
863 (while (search-forward ">-" nil t)
864 (replace-match "&GT-" nil t))
867 (defun www-html-display-paragraph (text)
869 (www-html-display-text text)
876 (defvar coded-charset-GlyphWiki-id-alist
878 (=adobe-japan1-0 "aj1-" 5 d nil)
879 (=adobe-japan1-1 "aj1-" 5 d nil)
880 (=adobe-japan1-2 "aj1-" 5 d nil)
881 (=adobe-japan1-3 "aj1-" 5 d nil)
882 (=adobe-japan1-4 "aj1-" 5 d nil)
883 (=adobe-japan1-5 "aj1-" 5 d nil)
884 (=adobe-japan1-6 "aj1-" 5 d nil)
886 (=decomposition@hanyo-denshi)
887 (=hanyo-denshi/ks "koseki-" 6 d nil)
888 (=>>hanyo-denshi/ks "koseki-" 6 d nil)
889 (=ucs@jis "u" 4 x nil)
890 (=ucs@cns "u" 4 x "-t")
891 (=jis-x0212 "jsp-" 4 x nil)
892 (=jis-x0213-1@2000 "jx1-2000-" 4 x nil)
893 (=jis-x0213-1@2004 "jx1-2004-" 4 x nil)
894 (=jis-x0213-2 "jx2-" 4 x nil)
896 (=daikanwa "dkw-" 5 d nil)
897 (=>>daikanwa "dkw-" 5 d nil)
898 (=gt-k "gt-k" 5 d nil)
899 (=jef-china3 "jc3-" 4 x nil)
901 (=ks-x1001 "k0-" 4 x nil)
902 (=jis-x0208@1978/1pr "j78-" 4 x nil)
903 (=jis-x0208@1978/-4pr "j78-" 4 x nil)
904 (=jis-x0208@1978 "j78-" 4 x nil)
905 (=>>>jis-x0208@1978 "j78-" 4 x nil)
906 (=>>jis-x0208@1978 "j78-" 4 x nil)
907 (=+>jis-x0208@1978 "j78-" 4 x nil)
908 (=ucs@JP "u" 4 x nil)
909 (=ucs@gb "u" 4 x "-g")
910 (=ucs@ks "u" 4 x "-k")
911 (=ucs@iso "u" 4 x "-u")
912 (=ucs@unicode "u" 4 x "-us")
913 (=big5-cdp "cdp-" 4 x nil)
914 (=>>big5-cdp "cdp-" 4 x nil)
915 (=cns11643-1 "c1-" 4 x nil)
916 (=cns11643-2 "c2-" 4 x nil)
917 (=cns11643-3 "c3-" 4 x nil)
918 (=cns11643-4 "c4-" 4 x nil)
919 (=cns11643-5 "c5-" 4 x nil)
920 (=cns11643-6 "c6-" 4 x nil)
921 (=cns11643-7 "c7-" 4 x nil)
922 (=jis-x0208 "j90-" 4 x nil)
923 (=>>>jis-x0208 "j90-" 4 x nil)
924 (=>>jis-x0208 "j90-" 4 x nil)
925 (=+>jis-x0208 "j90-" 4 x nil)
926 (=jis-x0208@1990 "j90-" 4 x nil)
927 (=>>>jis-x0208@1990 "j90-" 4 x nil)
928 (=>>jis-x0208@1990 "j90-" 4 x nil)
929 (=+>jis-x0208@1990 "j90-" 4 x nil)
930 (=jis-x0208@1983 "j83-" 4 x nil)
931 (=>>>jis-x0208@1983 "j83-" 4 x nil)
932 (=>>jis-x0208@1983 "j83-" 4 x nil)
933 (=+>jis-x0208@1983 "j83-" 4 x nil)
934 (=cbeta "cb" 5 d nil)
937 (defun char-GlyphWiki-id (char)
938 (let ((rest coded-charset-GlyphWiki-id-alist)
941 (setq spec (pop rest))
942 (null (setq ret (char-feature char (car spec))))))
946 (mapconcat #'char-GlyphWiki-id ret "-"))
947 (and (memq (car spec) '(=ucs@unicode '=ucs@iso))
949 ((and (or (encode-char char '=jis-x0208@1990)
950 (encode-char char '=jis-x0212)
951 (encode-char char '=jis-x0213-1))
952 (setq code (encode-char char '=ucs@jis)))
953 (format "u%04x" code)
955 ((and (or (encode-char char '=gb2312)
956 (encode-char char '=gb12345))
957 (setq code (encode-char char '=ucs@gb)))
958 (format "u%04x-g" code)
960 ((and (or (encode-char char '=cns11643-1)
961 (encode-char char '=cns11643-2)
962 (encode-char char '=cns11643-3)
963 (encode-char char '=cns11643-4)
964 (encode-char char '=cns11643-5)
965 (encode-char char '=cns11643-6)
966 (encode-char char '=cns11643-7))
967 (setq code (encode-char char '=ucs@cns)))
968 (format "u%04x-t" code)
970 ((and (encode-char char '=ks-x1001)
971 (setq code (encode-char char '=ucs@ks)))
972 (format "u%04x-k" code)
974 (format (format "%s%%0%d%s%s"
978 (or (nth 4 spec) ""))
985 (provide 'cwiki-common)
987 ;;; cwiki-common.el ends here