Fix character translation in org-protocol.el

This commit is contained in:
Carsten Dominik 2009-11-11 11:25:02 +01:00
parent 320b035ae8
commit a417a36bd2
2 changed files with 16 additions and 1 deletions

View File

@ -1,3 +1,7 @@
2009-11-11 Carsten Dominik <carsten.dominik@gmail.com>
* org-protocol.el (org-protocol-char-to-string): New defsubst.
2009-11-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-diary-entry-in-org-file): Add error

View File

@ -280,6 +280,17 @@ decode each split part."
(mapcar 'org-protocol-unhex-string split-parts))
split-parts)))
;; This inline function is needed in org-protocol-unhex-compound to do
;; the right thing to decode UTF-8 char integer values.
(eval-when-compile
(if (>= emacs-major-version 23)
(defsubst org-protocol-char-to-string(c)
"Defsubst to decode UTF-8 character values in emacs 23 and beyond."
(char-to-string sum))
(defsubst org-protocol-char-to-string (c)
"Defsubst to decode UTF-8 character values in emacs 22."
(string (decode-char 'ucs sum)))))
(defun org-protocol-unhex-string(str)
"Unhex hexified unicode strings as returned from the JavaScript function
encodeURIComponent. E.g. `%C3%B6' is the german Umlaut `ü'."
@ -331,7 +342,7 @@ encodeURIComponent. E.g. `%C3%B6' is the german Umlaut `ü'."
(setq sum (+ (lsh sum shift) val))
(if (> eat 0) (setq eat (- eat 1)))
(when (= 0 eat)
(setq ret (concat ret (char-to-string sum)))
(setq ret (concat ret (org-protocol-char-to-string sum)))
(setq sum 0))
)) ;; end (while bytes
ret ))