(www-uri-decode-char): Expect char-rep to be encoded as URI.
authorMORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
Wed, 17 Mar 2010 19:16:02 +0000 (04:16 +0900)
committerMORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
Wed, 17 Mar 2010 19:16:02 +0000 (04:16 +0900)
(www-uri-encode-char): Encode UCS characters as %XX encoding.
(www-format-feature-name-as-CCS): Insert space between prefix (...,
===>, ==>, =>, =>>, =>>>, ..., =) and main-name.
(www-html-display-text): Don't escape "&" except "&GT-".

cwiki-common.el

index 6569ac4..8ef14b7 100644 (file)
 (defun www-uri-decode-char (char-rep)
   (let (ccs cpos)
     (cond
-     ((string-match ":" char-rep)
+     ((string-match "%3A" char-rep)
       (setq ccs (substring char-rep 0 (match-beginning 0))
            cpos (substring char-rep (match-end 0)))
       (setq ccs (www-uri-decode-feature-name ccs))
       (if (numberp cpos)
          (decode-char ccs cpos))
       )
-     ((= (length char-rep) 1)
-      (aref char-rep 0)
+     (t
+      (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er))
+      (when (= (length char-rep) 1)
+       (aref char-rep 0))
       ))))
 
 (defun www-uri-encode-char (char)
-  (let ((ccs-list '(=ucs
-                   =cns11643-1 =cns11643-2 =cns11643-3
-                   =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7
-                   =gb2312 =gb12345
-                   =jis-x0208 =jis-x0208@1990
-                   =jis-x0212
-                   =cbeta =jef-china3
-                   =jis-x0213-1@2000 =jis-x0213-1@2004
-                   =jis-x0208@1983 =jis-x0208@1978
-                   =zinbun-oracle
-                   =daikanwa
-                   =gt =gt-k
-                   =big5
-                   =big5-cdp
-                   =>>jis-x0208 =>>jis-x0213-1
-                   =>jis-x0208 =>jis-x0213-1))
-       ccs ret)
-    (while (and ccs-list
-               (setq ccs (pop ccs-list))
-               (not (setq ret (encode-char char ccs 'defined-only)))))
-    (cond (ret
-          (format "%s:0x%X"
-                  (www-uri-encode-feature-name ccs)
-                  ret))
-         ((setq ccs (car (split-char char)))
-          (format "%s:0x%X"
-                  (www-uri-encode-feature-name ccs)
-                  (encode-char char ccs))))))
+  (if (encode-char char '=ucs)
+      (mapconcat
+       (lambda (byte)
+        (format "%%%02X" byte))
+       (encode-coding-string (char-to-string char) 'utf-8-mcs-er)
+       "")
+    (let ((ccs-list '(; =ucs
+                     =cns11643-1 =cns11643-2 =cns11643-3
+                     =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7
+                     =gb2312 =gb12345
+                     =jis-x0208 =jis-x0208@1990
+                     =jis-x0212
+                     =cbeta =jef-china3
+                     =jis-x0213-1@2000 =jis-x0213-1@2004
+                     =jis-x0208@1983 =jis-x0208@1978
+                     =zinbun-oracle
+                     =daikanwa
+                     =gt =gt-k
+                     =big5
+                     =big5-cdp
+                     =>>jis-x0208 =>>jis-x0213-1
+                     =>jis-x0208 =>jis-x0213-1))
+         ccs ret)
+      (while (and ccs-list
+                 (setq ccs (pop ccs-list))
+                 (not (setq ret (encode-char char ccs 'defined-only)))))
+      (cond (ret
+            (format "%s:0x%X"
+                    (www-uri-encode-feature-name ccs)
+                    ret))
+           ((setq ccs (car (split-char char)))
+            (format "%s:0x%X"
+                    (www-uri-encode-feature-name ccs)
+                    (encode-char char ccs)))))))
 
 
 ;;; @ Feature name presentation
           (symbol-name feature-name)
           "-"))
         (dest (upcase (pop rest))))
+    (when (string-match "^=+>*" dest)
+      (setq dest (concat (substring dest 0 (match-end 0))
+                        " "
+                        (substring dest (match-end 0)))))
     (cond
      (rest
       (while (cdr rest)
        nil t))
      (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er)
      (goto-char (point-min))
-     (while (search-forward "&" nil t)
-       (replace-match "&amp;" nil t))
+     (while (search-forward "&GT-" nil t)
+       (replace-match "&amp;GT-" nil t))
      (buffer-string))))
 
 (defun www-html-display-paragraph (text)