[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] Re: Babel, Python and UTF-8
From: |
Vincent Beffara |
Subject: |
[Orgmode] Re: Babel, Python and UTF-8 |
Date: |
Thu, 02 Dec 2010 17:44:14 +0100 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (darwin) |
>> #+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
- Re: [Orgmode] Re: Babel, Python and UTF-8, (continued)
- Re: [Orgmode] Re: Babel, Python and UTF-8, Eric Schulte, 2010/12/03
- [Orgmode] Re: Babel, Python and UTF-8, Vincent Beffara, 2010/12/03
- Re: [Orgmode] Re: Babel, Python and UTF-8, Eric Schulte, 2010/12/05
- [Orgmode] Re: Babel, Python and UTF-8, Dan Davison, 2010/12/06
- Re: [Orgmode] Re: Babel, Python and UTF-8, Eric S Fraga, 2010/12/06
- Re: [Orgmode] Re: Babel, Python and UTF-8, Thomas S. Dye, 2010/12/06
- [Orgmode] Re: Babel, Python and UTF-8, Achim Gratz, 2010/12/06
- Re: [Orgmode] Re: Babel, Python and UTF-8, Thomas S. Dye, 2010/12/06
- [Orgmode] Re: Babel, Python and UTF-8, Dan Davison, 2010/12/06
- [Orgmode] Re: Babel, Python and UTF-8, Sébastien Vauban, 2010/12/02
- [Orgmode] Re: Babel, Python and UTF-8,
Vincent Beffara <=
- Re: [Orgmode] Re: Babel, Python and UTF-8, Christopher Allan Webber, 2010/12/03