From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastian Rose Subject: Re: Re: org-protocol bug Date: Wed, 11 Nov 2009 10:06:36 +0100 Message-ID: <87fx8lzazn.fsf@gmx.de> References: <20091111004014.4199f1ca.andy13@gmx.net> <87tyx1zp3q.fsf@gmx.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N89AD-0000dJ-PP for emacs-orgmode@gnu.org; Wed, 11 Nov 2009 04:06:53 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N89A8-0000Wb-ER for emacs-orgmode@gnu.org; Wed, 11 Nov 2009 04:06:52 -0500 Received: from [199.232.76.173] (port=41045 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N89A8-0000W6-3p for emacs-orgmode@gnu.org; Wed, 11 Nov 2009 04:06:48 -0500 Received: from mail.gmx.net ([213.165.64.20]:41271) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1N89A7-000719-CI for emacs-orgmode@gnu.org; Wed, 11 Nov 2009 04:06:47 -0500 In-Reply-To: <87tyx1zp3q.fsf@gmx.de> (Sebastian Rose's message of "Wed, 11 Nov 2009 05:01:45 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Emacs-orgmode mailing list --=-=-= Hi Carsten and Andreas, thanks to Kenichi Handa, here is a proposal to fix the issus mentioned below. I tested it in emacs 22 and 23 and it seems to work just fine. Carsten, as always if I use some new elisp construct, please review the patch. I used `eval-when-compile' and `defsubst' to inline the char-to-string function, since it might be called very often, depending on the amount of text passed to emacs through org-protocol. Andreas, could you check if it works for you, too? --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=org-protocol-char-to-string.patch Content-Transfer-Encoding: quoted-printable Content-Description: Decode UTF-8 char integer values in emacs 22, too diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el index 133fae4..9b34ed9 100644 --- a/lisp/org-protocol.el +++ b/lisp/org-protocol.el @@ -280,6 +280,19 @@ decode each split part." (mapcar 'org-protocol-unhex-string split-parts)) split-parts))) =20 + +;; 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 (>=3D 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)) + (defun 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 `=C3=BC'." @@ -331,7 +344,7 @@ encodeURIComponent. E.g. `%C3%B6' is the german Umlaut = `=C3=BC'." (setq sum (+ (lsh sum shift) val)) (if (> eat 0) (setq eat (- eat 1))) (when (=3D 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 )) --=-=-= > Andreas Burtzlaff writes: >> Hello Sebastian, >> >> I'm not sure you noticed the org-protocol bug in this thread on the >> org-mode list: >> http://www.mail-archive.com/emacs-orgmode@gnu.org/msg18673.html >> >> To sum it up, when the title of a page contains an &ndash then the error >> org-protocol-unhex-compound: Invalid character: 8211, #o20023, #x2013 >> occurs when invoking remember in Emacs 22, not in Emacs 23. >> >> Just wondering whether you have any idea how this could be fixed. Sebastian --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--