From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vincent Beffara Subject: Re: Babel, Python and UTF-8 Date: Thu, 02 Dec 2010 17:44:14 +0100 Message-ID: References: <87fwuhas6t.fsf@gmail.com> <804oawupfa.fsf@missioncriticalit.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from [140.186.70.92] (port=53480 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POCHw-00057D-UC for emacs-orgmode@gnu.org; Thu, 02 Dec 2010 11:47:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1POCGh-0002jh-Jh for emacs-orgmode@gnu.org; Thu, 02 Dec 2010 11:45:44 -0500 Received: from lo.gmane.org ([80.91.229.12]:55246) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1POCGh-0002jY-9r for emacs-orgmode@gnu.org; Thu, 02 Dec 2010 11:44:27 -0500 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1POCGg-0006Iz-MT for emacs-orgmode@gnu.org; Thu, 02 Dec 2010 17:44:26 +0100 Received: from 140.77.141.68 ([140.77.141.68]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 Dec 2010 17:44:26 +0100 Received: from vbeffara by 140.77.141.68 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 Dec 2010 17:44:26 +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: emacs-orgmode@gnu.org >> #+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