From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: org-babel, python, encoding and table Date: Wed, 29 May 2013 09:00:18 -0400 Message-ID: <87ehcq0wm5.fsf@gmail.com> References: <87zjw6spxt.fsf@gmail.com> <518A0E9E.7070309@easy-emacs.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:48698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uhg00-0008Uv-5t for emacs-orgmode@gnu.org; Wed, 29 May 2013 09:01:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uhfzv-0005Zw-0B for emacs-orgmode@gnu.org; Wed, 29 May 2013 09:01:04 -0400 Received: from mail-qe0-f47.google.com ([209.85.128.47]:55703) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uhfzu-0005Zf-RU for emacs-orgmode@gnu.org; Wed, 29 May 2013 09:00:58 -0400 Received: by mail-qe0-f47.google.com with SMTP id f6so4171016qej.34 for ; Wed, 29 May 2013 06:00:58 -0700 (PDT) In-Reply-To: (Roland DONAT's message of "Wed, 29 May 2013 12:18:33 +0000 (UTC)") 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: Roland DONAT Cc: emacs-orgmode@gnu.org > > 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 =3D ( ( "=C3=A9", "a" ), ( "a", "=C3=A0" ) ) > 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= =20 > 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 ( ( "=C3= =A9", "a"=20 > ), ( "a", "=C3=A0" ) ) (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=20 > relevant lead??? > This does seem to be in the right direction. This is similar to my diagnosis of the non-session case [1]. If the python process prints weird hex character values (e.g., '\xc3\xa0') instead of utf8 characters (e.g., "=C3=A0"), then Babel will insert the hex values into the buffer. As I recall switching to python3 solved this problem? For the session case, it may be possible to fix this by changing the python code in the `org-babel-python-evaluate-session' function around line 300 in ob-python.el. Cheers, > > Thanks in advance for any help... > > Roland. > > > > Footnotes:=20 [1] http://article.gmane.org/gmane.emacs.orgmode/71866 --=20 Eric Schulte http://cs.unm.edu/~eschulte