From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Allan Webber Subject: Re: Re: Babel, Python and UTF-8 Date: Fri, 03 Dec 2010 08:56:42 -0600 Message-ID: <87lj4629cl.fsf@dustycloud.org> References: <87fwuhas6t.fsf@gmail.com> <804oawupfa.fsf@missioncriticalit.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=42153 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POX40-0004w7-Jb for emacs-orgmode@gnu.org; Fri, 03 Dec 2010 09:56:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1POX3z-0001OH-3z for emacs-orgmode@gnu.org; Fri, 03 Dec 2010 09:56:44 -0500 Received: from li28-75.members.linode.com ([75.127.72.75]:47979) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1POX3z-0001O2-0T for emacs-orgmode@gnu.org; Fri, 03 Dec 2010 09:56:43 -0500 In-Reply-To: (Vincent Beffara's message of "Thu, 02 Dec 2010 17:44:14 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Vincent Beffara Cc: emacs-orgmode@gnu.org (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 writes: >>> #+begin_src python >>> # -*- coding: utf-8 -*- >>> s =3D "=C3=A9" >>> #+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 "=C3=A9" 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. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode