From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sebastian Rose Newsgroups: gmane.emacs.devel Subject: Internal coding system - Need advice 22 v. 23 Date: Wed, 11 Nov 2009 06:00:15 +0100 Message-ID: <87pr7pzme8.fsf@gmx.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1257915649 5603 80.91.229.12 (11 Nov 2009 05:00:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 11 Nov 2009 05:00:49 +0000 (UTC) To: emacs-devel Mailinglist Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 11 06:00:41 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N85Ju-0007jd-90 for ged-emacs-devel@m.gmane.org; Wed, 11 Nov 2009 06:00:38 +0100 Original-Received: from localhost ([127.0.0.1]:33107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N85Jt-0003x1-T5 for ged-emacs-devel@m.gmane.org; Wed, 11 Nov 2009 00:00:37 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N85Jn-0003we-Sr for emacs-devel@gnu.org; Wed, 11 Nov 2009 00:00:31 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N85Ji-0003u0-Qs for emacs-devel@gnu.org; Wed, 11 Nov 2009 00:00:30 -0500 Original-Received: from [199.232.76.173] (port=58571 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N85Ji-0003tr-DM for emacs-devel@gnu.org; Wed, 11 Nov 2009 00:00:26 -0500 Original-Received: from mail.gmx.net ([213.165.64.20]:44851) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1N85Jh-0004Bd-NO for emacs-devel@gnu.org; Wed, 11 Nov 2009 00:00:26 -0500 Original-Received: (qmail invoked by alias); 11 Nov 2009 05:00:21 -0000 Original-Received: from unknown (EHLO beteigeuze.gmx.de) [188.46.69.186] by mail.gmx.net (mp011) with SMTP; 11 Nov 2009 06:00:21 +0100 X-Authenticated: #8529601 X-Provags-ID: V01U2FsdGVkX19geLM6yAlgmDUl1NFlyfhZ8hu0cW/khZZOW47CI/ nuLbBtWlExvCJt User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-Y-GMX-Trusted: 0 X-FuHaFi: 0.53 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:116826 Archived-At: Hi emacs experts, please, could someone help me to understand the internal coding system of emacs-22? Or simply point me to a function that correctly decodes multibyte characters in emacs-22? Here is why: To send unicode text to emacs via org-protocol, I wrote a function, that decodes all those hex-encoded characters (e.g. `%C3%B6' is the German Umlaut `=C3=BC'). That function `org-protocol-unhex-string' is defunned in org/lisp/org-protocol.el. It works perfectly for emacs-23. For emacs-22 this does _not_ work, however. The problem occurs, if `char-to-string' is called with an unicode character. E.g. (char-to-string 8211) perfectly returns a dash in emacs-23. `org-protocol-unhex-string' works like a charme for texts like those on http://www.welcome2japan.cn/ - in emacs-23. If I evaluate the same expression in emacs-22, I get an error (see backtrace below) and (prin1-char 8211) returns nil. There must be a way to correctly decode multibyte characters in emacs-22. Thanks in advance, Sebastian Debugger entered--Lisp error: (error "Invalid character: 8211, #o20023, #x2013") char-to-string(8211) (concat ret (char-to-string sum)) (setq ret (concat ret (char-to-string sum))) (progn (setq ret (concat ret ...)) (setq sum 0)) (if (=3D 0 eat) (progn (setq ret ...) (setq sum 0))) (when (=3D 0 eat) (setq ret (concat ret ...)) (setq sum 0)) (let* ((b ...) (a ...) (b ...) (c1 ...) (c2 ...) (val ...) (shift ...) (xor ...)) (if (>=3D val 192) (setq eat shift)) (setq val (logxor val xor)) (setq sum (+ ... val)) (if (> eat 0) (setq eat ...)) (when (=3D 0 eat) (setq ret ...) (setq sum 0))) (while bytes (let* (... ... ... ... ... ... ... ...) (if ... ...) (setq val ...) (setq sum ...) (if ... ...) (when ... ... ...))) (let* ((bytes ...) (ret "") (eat 0) (sum 0)) (while bytes (let* ... ... ... ... ... ...)) ret) org-protocol-unhex-compound("%20%E2%80%93%20") (let* ((start ...) (end ...) (hex ...) (replacement ...)) (setq tmp (concat tmp ... replacement)) (setq str (substring str end))) (while (string-match "\\(% [0-9a-f][0-9a-f]\\)+" str) (let* (... ... ... ...) (setq tmp ...) (setq str ...))) (let ((tmp "") (case-fold-search t)) (while (string-match "\ \(%[0-9a-f][0-9a-f]\\)+" str) (let* ... ... ...)) (setq tmp (concat tmp str)) tmp) org-protocol-unhex-string("org-protocol.el%20%E2%80%93% 20Intercept%20calls%20from%20emacsclient%20to%20trigger%20custom% 20actions") mapcar(org-protocol-unhex-string ("http%3A%2F%2Forgmode.org% 2Fworg%2Forg-contrib%2Forg-protocol.php" "org-protocol.el%20%E2%80%93% 20Intercept%20calls%20from%20emacsclient%20to%20trigger%20custom% 20actions" "")) (if (fboundp unhexify) (mapcar unhexify split-parts) (mapcar (quote org-protocol-unhex-string) split-parts)) (if unhexify (if (fboundp unhexify) (mapcar unhexify split-parts) (mapcar ... split-parts)) split-parts) (let* ((sep ...) (split-parts ...)) (if unhexify (if ... ... ...) split-parts)) org-protocol-split-data("http%3A %2F%2Forgmode.org%2Fworg%2Forg-contrib% 2Forg-protocol.php/org-protocol.el%20%E2%80%93%20Intercept%20calls% 20from%20emacsclient%20to%20trigger%20custom%20actions/" t) (let* ((parts ...) (template ...) (url ...) (type ...) (title ...) (region ...) (orglink ...) remember-annotation-functions) (setq org-stored-links (cons ... org-stored-links)) (kill-new orglink) (org-store-link-props :type type :link url :description title :initial region) (raise-frame) (org-remember nil (string-to-char template))) (if (and (boundp ...) (fboundp ...)) (let* (... ... ... ... ... ... ... remember-annotation-functions) (setq org-stored-links ...) (kill-new orglink) (org-store-link-props :type type :link url :description title :initial region) (raise-frame) (org-remember nil ...)) (message "Org-mode not loaded.")) org-protocol-remember("http%3A%2F%2Forgmode.org %2Fworg%2Forg-contrib%2Forg-protocol.php/org-protocol.el%20%E2%80%93% 20Intercept%20calls%20from%20emacsclient%20to%20trigger%20custom% 20actions/") funcall(org-protocol-remember "http%3A%2F%2Forgmode.org% 2Fworg%2Forg-contrib%2Forg-protocol.php/org-protocol.el%20%E2%80%93% 20Intercept%20calls%20from%20emacsclient%20to%20trigger%20custom% 20actions/") (throw (quote fname) (funcall func result)) (if greedy nil (throw (quote fname) (funcall func result))) (unless greedy (throw (quote fname) (funcall func result))) (progn (unless greedy (throw ... ...)) (funcall func result) (throw (quote fname) t)) (if (fboundp func) (progn (unless greedy ...) (funcall func result) (throw ... t))) (when (fboundp func) (unless greedy (throw ... ...)) (funcall func result) (throw (quote fname) t)) (let* ((func ...) (greedy ...) (splitted ...) (result ...)) (when (plist-get ... :kill-client) (message "Greedy org-protocol handler. Killing client.") (server-edit)) (when (fboundp func) (unless greedy ...) (funcall func result) (throw ... t))) (progn (let* (... ... ... ...) (when ... ... ...) (when ... ... ... ...))) (if (string-match proto fname) (progn (let* ... ... ...))) (when (string-match proto fname) (let* (... ... ... ...) (when ... ... ...) (when ... ... ... ...))) (let ((proto ...)) (when (string-match proto fname) (let* ... ... ...))) (while --cl-dolist-temp-- (setq prolist (car --cl-dolist-temp--)) (let (...) (when ... ...)) (setq --cl-dolist-temp-- (cdr --cl-dolist-temp--))) (let ((--cl-dolist-temp-- sub-protocols) prolist) (while --cl-dolist-temp-- (setq prolist ...) (let ... ...) (setq --cl-dolist-temp-- ...)) nil) (catch (quote --cl-block-nil--) (let (... prolist) (while --cl-dolist-temp-- ... ... ...) nil)) (cl-block-wrapper (catch (quote --cl-block-nil--) (let ... ... nil))) (block nil (let (... prolist) (while --cl-dolist-temp-- ... ... ...) nil)) (dolist (prolist sub-protocols) (let (...) (when ... ...))) (progn (dolist (prolist sub-protocols) (let ... ...))) (if (string-match the-protocol fname) (progn (dolist ... ...))) (when (string-match the-protocol fname) (dolist (prolist sub-protocols) (let ... ...))) (let ((the-protocol ...)) (when (string-match the-protocol fname) (dolist ... ...))) (catch (quote fname) (let (...) (when ... ...)) fname) (let ((sub-protocols ...)) (catch (quote fname) (let ... ...) fname)) org-protocol-check-filename-for-protocol ("/home/andy/org-protocol:/remember:/http%3A%2F%2Forgmode.org%2Fworg% 2Forg-contrib%2Forg-protocol.php/org-protocol.el%20%E2%80%93%20Intercept %20calls%20from%20emacsclient%20to%20trigger%20custom% 20actions/" (("/home/andy/org-protocol:/remember:/http%3A%2F% 2Forgmode.org%2Fworg%2Forg-contrib%2Forg-protocol.php/org-protocol.el% 20%E2%80%93%20Intercept%20calls%20from%20emacsclient%20to%20trigger% 20custom%20actions/" 1 0)) (#>)) byte-code ( [flist var --cl-dolist-temp-- fname client files nil expand-file-name org-protocol-check-filename-for-protocol t throw greedy delq] 5) server-visit-files ((("/home/andy/org-protocol:/remember:/http%3A%2F%2Forgmode.org%2Fworg% 2Forg-contrib%2Forg-protocol.php/org-protocol.el%20%E2%80%93%20Intercept %20calls%20from%20emacsclient%20to%20trigger%20custom%20actions/" 1 0)) (#>) nil) byte-code( [proc string prev --cl-proc-- default-enable-multibyte-characters file-name-coding-system process-get :authenticated string-match "-auth \ \(.*?\\)\n" match-string 1 :auth-key 0 nil process-put t server-log "Authentication successful" "Authentication failed" process-send-string delete-process throw --cl-block-server-process-filter-- :previous-string recursion-depth run-with-timer make-symbol "--proc--" lambda (&rest --cl-rest--) apply # [(G47000) [G47000 server-process-filter ""] 3] quote --cl-rest-- top-level (byte-code [mapc #[... [buffer isearch-mode boundp isearch-cancel] 2] buffer-list] 3) ((quit ...)) "\n" "[^ ]* " "-nowait" "-eval" "-display" "\\([^ ]*\\) " server-unquote-arg err (byte-code [display tmp-frame server-select-display] 2) ((error ...)) "\\`\\+[0-9]+ \\'" string-to-number ...] 10) server-process-filter(#> "/home/andy/org-protocol://remember://http%3A%2F%2Forgmode.org% 2Fworg%2Forg-contrib%2Forg-protocol.php/org-protocol.el%20%E2%80%93% 20Intercept%20calls%20from%20emacsclient%20to%20trigger%20custom% 20actions/ \n")