emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] Re: Babel, Python and UTF-8


From: Christopher Allan Webber
Subject: Re: [Orgmode] Re: Babel, Python and UTF-8
Date: Fri, 03 Dec 2010 08:56:42 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

(Also worth mentioning that python 3 allows you to use actual unicode
characters inside strings in the file, not \xff chars; not sure if
org-babel needs to change its habits between python2 and python3?)

Vincent Beffara <address@hidden> writes:

>>> #+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:
>
> #+begin_src python :shebang sldfkj
> return 1
> #+end_src
>
> Anyway, :prefix cannot hurt I guess ...
>
>         /v
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode



reply via email to

[Prev in Thread] Current Thread [Next in Thread]