From: Vincent Beffara <vbeffara@ens-lyon.fr>
To: emacs-orgmode@gnu.org
Subject: Re: Babel, Python and UTF-8
Date: Thu, 02 Dec 2010 17:44:14 +0100 [thread overview]
Message-ID: <m27hfsyvj5.fsf@ens-lyon.fr> (raw)
In-Reply-To: 804oawupfa.fsf@missioncriticalit.com
>> #+begin_src python
>> # -*- coding: utf-8 -*-
>> s = "é"
>> #+end_src
>
> I'm not sure to understand your problem. In fact, the problem is not
> about "inserting a prefix to the block", it's about the coding system
> itself, I guess.
>
> Your "é" in your Org buffer, how is it encoded? Is your Org buffer an
> UTF-8 one, or a Latin-1?
Doesn't really matter, in fact ... Whenever a python file contains a
non-ascii character (utf-8 or latin-1) it insists on finding an
indication of the encoding within the file. If latin-1, it finds \xe9,
if utf-8, it finds \xc3, but in both cases it raises this:
# SyntaxError: Non-ASCII character '\xe9' in file /Users/vincent/toto.py
# on line 1, but no encoding declared; see
# http://www.python.org/peps/pep-0263.html for details
That's even if the character in question lies within a string. That
makes a lot of sense in terms of portability, but it makes on-the-fly
evaluation a bit more complicated.
> In the second, you want an ISO Latin 1 block of text to be tangled or
> executed as UTF-8. Is this right?
No, I want everything in utf-8, there is no converting to do anywhere,
just telling python that it is utf-8.
> Isn't such a prefix already available through the "shebang" option:
> can't it be multiline? Anyway, I don't think it's the problem here...
Hmm, didn't know about :shebang, but it seems to be ignored (at least
for python) because this works without a syntax error:
--8<---------------cut here---------------start------------->8---
#+begin_src python :shebang sldfkj
return 1
#+end_src
--8<---------------cut here---------------end--------------->8---
Anyway, :prefix cannot hurt I guess ...
/v
next prev parent reply other threads:[~2010-12-02 16:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-01 23:50 Babel, Python and UTF-8 Vincent Beffara
2010-12-02 1:18 ` Eric Schulte
2010-12-02 1:36 ` Vincent Beffara
2010-12-02 9:11 ` Sébastien Vauban
2010-12-02 19:34 ` Eric Schulte
2010-12-02 20:10 ` Sébastien Vauban
2010-12-03 10:27 ` Vincent Beffara
2010-12-03 11:27 ` Sébastien Vauban
2010-12-03 14:30 ` Eric Schulte
2010-12-03 15:43 ` Vincent Beffara
2010-12-05 15:30 ` Eric Schulte
2010-12-06 9:42 ` Dan Davison
2010-12-06 11:53 ` Eric S Fraga
2010-12-06 16:42 ` Thomas S. Dye
2010-12-06 18:07 ` Achim Gratz
2010-12-06 18:40 ` Thomas S. Dye
2010-12-06 18:23 ` Dan Davison
2010-12-02 14:29 ` Eric Schulte
2010-12-02 16:12 ` Vincent Beffara
2010-12-02 18:23 ` Dan Davison
2010-12-02 19:36 ` Eric Schulte
2010-12-02 20:05 ` Sébastien Vauban
2010-12-02 16:09 ` Sébastien Vauban
2010-12-02 16:44 ` Vincent Beffara [this message]
2010-12-03 14:56 ` Christopher Allan Webber
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=m27hfsyvj5.fsf@ens-lyon.fr \
--to=vbeffara@ens-lyon.fr \
--cc=emacs-orgmode@gnu.org \
/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).