From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roland DONAT Subject: Re: org-babel, python, encoding and table Date: Wed, 29 May 2013 12:18:33 +0000 (UTC) Message-ID: References: <87zjw6spxt.fsf@gmail.com> <518A0E9E.7070309@easy-emacs.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:36968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhfLO-00017t-RU for emacs-orgmode@gnu.org; Wed, 29 May 2013 08:19:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhfLG-0007wS-Gf for emacs-orgmode@gnu.org; Wed, 29 May 2013 08:19:06 -0400 Received: from plane.gmane.org ([80.91.229.3]:33992) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhfLG-0007vd-0v for emacs-orgmode@gnu.org; Wed, 29 May 2013 08:18:58 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UhfL8-0004z8-Dt for emacs-orgmode@gnu.org; Wed, 29 May 2013 14:18:50 +0200 Received: from 163.116.6.12 ([163.116.6.12]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 29 May 2013 14:18:50 +0200 Received: from roland.donat by 163.116.6.12 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 29 May 2013 14:18:50 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Andreas Röhler easy-emacs.de> writes: > > Am 07.05.2013 18:41, schrieb Eric Schulte: > >> #+NAME: test2 > >> #+begin_src python :results value :preamble # -*- coding: utf-8 -*- :return > >> a > >> a = ( ( "é", "a" ), ( "a", "à" ) ) > >> b = "é" > >> #+end_src > >> > >> #+RESULTS: test2 > >> | \303\251 | a | > >> | a | \303\240 | > >> > > > > Maybe this isn't an execution problem, but is rather a buffer encoding > > problem. I executed your example above in a small buffer (attached). I > > then saved this buffer and was forced to specify an encoding, I selected > > utf8. If I cat the resulting file from disk, the accented characters > > appear correctly. > > > > Confirming this. > > BTW also return a[0][0] displays correct so far. > > Cheers, > > Andreas > > Hello, Just an update about this post. I've kept on digging on the problem of org-babel python results that produces encoding problems in the emacs buffer when the requested results is turned into a org table. To remind and illustrate the problem, here is an example : #+name: pytab-test #+begin_src python :results value :session :preamble # -*- coding: utf-8 -*- :return a a = ( ( "é", "a" ), ( "a", "à" ) ) a #+end_src #+TBLNAME: pytab-test | \303\251 | a | | a | \303\240 | I have then two problems : 1. The characters are not well displayed in the buffer 2. If I try to save the buffer, emacs doesn't recognize the encoding and tells me that "utf-8-unix cannot encode these: \303 \251 [...] So I decided to inspect what happened during the Python session... Basically, Org-babel just write the str conversion of my tuple ( ( "é", "a" ), ( "a", "à" ) ) (that appears (('\xc3\xa9', 'a'), ('a', '\xc3\xa0')) in the python interpreter) in a temporary file. Then looking in this temporary file, I see that the strange characters are written directly \xc3, \xa9, etc. Consequently, my guess is that org-babel has maybe some difficulties to deal with these characters while reading the temporary file before displaying the results in the buffer. Unfortunately, this is just a guess and even less a solution... But am I on relevant lead??? Thanks in advance for any help... Roland.