From: Eric Schulte <schulte.eric@gmail.com>
To: Roland DONAT <roland.donat@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-babel, python, encoding and table
Date: Wed, 29 May 2013 09:00:18 -0400 [thread overview]
Message-ID: <87ehcq0wm5.fsf@gmail.com> (raw)
In-Reply-To: <loom.20130529T141634-491@post.gmane.org> (Roland DONAT's message of "Wed, 29 May 2013 12:18:33 +0000 (UTC)")
>
> 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???
>
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., "à"), 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:
[1] http://article.gmane.org/gmane.emacs.orgmode/71866
--
Eric Schulte
http://cs.unm.edu/~eschulte
next prev parent reply other threads:[~2013-05-29 13:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-07 12:55 org-babel, python, encoding and table Roland Donat
2013-05-07 16:41 ` Eric Schulte
2013-05-07 17:34 ` Andreas Röhler
2013-05-07 18:18 ` Eric Schulte
2013-05-07 18:45 ` Andreas Röhler
2013-05-07 19:20 ` Nick Dokos
2013-05-07 19:40 ` Andreas Röhler
2013-05-07 20:05 ` Nick Dokos
2013-05-08 6:21 ` Andreas Röhler
2013-05-07 19:44 ` Roland Donat
2013-05-07 19:52 ` Andreas Röhler
2013-05-08 8:36 ` Andreas Röhler
2013-05-29 12:18 ` Roland DONAT
2013-05-29 13:00 ` Eric Schulte [this message]
2013-05-29 23:54 ` Christian Wittern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ehcq0wm5.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=roland.donat@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).