From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniele Pizzolli Subject: Re: Division of Org documentation: Org manual and Worg Date: Wed, 18 May 2016 12:18:37 +0200 Message-ID: <87a8jnzzzzsm82@me.localhost.invalid> References: <2016-05-08T10-21-00@devnull.Karl-Voit.at> <2016-05-17T16-45-38@devnull.Karl-Voit.at> <2016-05-18T09-06-50@devnull.Karl-Voit.at> <874m9vzzzzu6qt@me.localhost.invalid> <87vb2bagby.fsf@gmx.us> <87inybzzzzsmos@me.localhost.invalid> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2yZ6-0003PF-Ez for emacs-orgmode@gnu.org; Wed, 18 May 2016 06:18:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2yZ1-0000y6-2A for emacs-orgmode@gnu.org; Wed, 18 May 2016 06:18:56 -0400 In-Reply-To: <87inybzzzzsmos@me.localhost.invalid> (Daniele Pizzolli's message of "Wed, 18 May 2016 12:08:35 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" Cc: bzg@gnu.org, emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain On Wed, May 18 2016, Daniele Pizzolli wrote: > On Wed, May 18 2016, Rasmus wrote: > >> Daniele Pizzolli writes: >> >>> It would be nice to add them to the documentation, but I have not yet >>> figured out what is the appropriate way to send the patch! >> >> /That/ information happens to be on Worg :) >> >> http://orgmode.org/worg/org-contribute.html > > Thanks Rasmus, > > So... here is the patch for worg about python and utf-8! I skipped > the part related to the tables, since I do not have a clean > workaround. Oops, I correct a couple of typos with this one. Sorry for the noise. Daniele --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-Add-caveats-about-uft-8-strings.patch Content-Transfer-Encoding: quoted-printable >From e885c2d7654dcf78cf37e5fd5b1e104545ecbd2f Mon Sep 17 00:00:00 2001 From: Daniele Pizzolli Date: Wed, 18 May 2016 11:55:00 +0200 Subject: [PATCH 1/1] Add caveats about uft-8 strings --- org-contrib/babel/languages/ob-doc-python.org | 52 +++++++++++++++++++++++= +++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/org-contrib/babel/languages/ob-doc-python.org b/org-contrib/ba= bel/languages/ob-doc-python.org index 968a8bc..8acfbff 100644 --- a/org-contrib/babel/languages/ob-doc-python.org +++ b/org-contrib/babel/languages/ob-doc-python.org @@ -25,7 +25,7 @@ #+end_html =20 -* Template Checklist [10/12] :noexport: +* Template Checklist [11/14] :noexport: - [X] Revise #+TITLE: - [X] Indicate #+AUTHOR: - [X] Add #+EMAIL: @@ -42,6 +42,8 @@ - [ ] Describe [[Result%20Types][Result Types]] - [ ] Describe [[Other]] differences from supported languages - [X] Provide brief [[Examples%20of%20Use][Examples of Use]] + - [X] Add caveats about utf-8 in strings + - [ ] Add caveats about utf-8 in tables * Introduction Python is a high-level, readable, interpreted language which can be used for many common computing tasks. It runs on most modern @@ -242,3 +244,51 @@ return 'images/python-matplot-fig.png' # return filena= me to org-mode =20 #+end_example [[file:images/python-matplot-fig.png]] + +* Caveats + +You need some care in order to pass utf-8 strings to python. + +** passing utf-8 strings to python + +#+begin_example +#+NAME: unicode_str +,#+BEGIN_EXAMPLE +=E2=80=9Cthis string is not ascii!=E2=80=9D +,#+END_EXAMPLE +#+end_example + +#+begin_example +#+NAME: error-in-passing-var +#+BEGIN_SRC python :var data=3Dunicode_str +return data +#+END_SRC +#+end_example + +#+begin_example +#+RESULTS: error-in-passing-var +#+end_example + +Will produce no output and prints the following message in the buffer +=3D*Org-Babel Error Output*=3D: + +#+BEGIN_EXAMPLE + File "", line 3 +SyntaxError: Non-ASCII character '\xe2' in file on line 3, but no = encoding declared; see http://www.python.org/peps/pep-0263.html for details +#+END_EXAMPLE + +** passing utf-8 strings to python with workaround + +A workaround is to use =3D:preamble=3D with the value =3D# -*- coding:utf-= 8 -*-=3D + +#+begin_example +#+NAME: ok-in-passing-var +#+BEGIN_SRC python :preamble "# -*- coding: utf-8 -*-" :var data=3Dunicode= _str +return data +#+END_SRC +#+end_example + +#+begin_example +#+RESULTS: ok-in-passing-var +: =E2=80=9Cthis string is not ascii!=E2=80=9D +#+end_example --=20 2.1.4 --=-=-=--