From: Daniele Pizzolli <dan@toel.it>
To: emacs-orgmode@gnu.org
Cc: bzg@gnu.org
Subject: Re: Division of Org documentation: Org manual and Worg
Date: Wed, 18 May 2016 12:08:35 +0200 [thread overview]
Message-ID: <87inybzzzzsmos@me.localhost.invalid> (raw)
In-Reply-To: <87vb2bagby.fsf@gmx.us> (rasmus@gmx.us's message of "Wed, 18 May 2016 11:03:13 +0200")
[-- Attachment #1: Type: text/plain, Size: 477 bytes --]
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.
Best,
Daniele
[-- Attachment #2: 0001-Add-caveats-about-uft-8-strings.patch --]
[-- Type: text/x-diff, Size: 2609 bytes --]
From 91941d90d26e1715447fecc255d7976c0895e75d Mon Sep 17 00:00:00 2001
From: Daniele Pizzolli <dan@toel.it>
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/babel/languages/ob-doc-python.org
index 968a8bc..e4619ed 100644
--- a/org-contrib/babel/languages/ob-doc-python.org
+++ b/org-contrib/babel/languages/ob-doc-python.org
@@ -25,7 +25,7 @@
</div>
#+end_html
-* 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 filename to org-mode
#+end_example
[[file:images/python-matplot-fig.png]]
+
+* Caveats
+
+** passing utf-8 strings to python
+
+You need some care in order to pass utf-8 strings to python.
+
+#+begin_example
+#+NAME: unicode_str
+,#+BEGIN_EXAMPLE
+“this string is not ascii!”
+,#+END_EXAMPLE
+#+end_example
+
+#+begin_example
+#+NAME: error-in-passing-var
+#+BEGIN_SRC python :var data=unicode_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
+=*Org-Babel Error Output*=:
+
+#+BEGIN_EXAMPLE
+ File "<stdin>", line 3
+SyntaxError: Non-ASCII character '\xe2' in file <stdin> 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 =:preamble= with wthe value =# -*- coding:utf-8 -*-=
+
+#+begin_example
+#+NAME: ok-in-passing-var
+#+BEGIN_SRC python :preamble "# -*- coding: utf-8 -*-" :var data=unicode_str
+return data
+#+END_SRC
+#+end_example
+
+#+begin_example
+#+RESULTS: ok-in-passing-var
+: “this string is not ascii!”
+#+end_example
--
2.1.4
next prev parent reply other threads:[~2016-05-18 10:09 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-08 8:31 Mixing Python2 and Python3 blocks in one file Karl Voit
2016-05-08 15:13 ` Karl Voit
2016-05-17 14:24 ` William Henney
2016-05-17 14:54 ` Karl Voit
2016-05-17 15:37 ` John Kitchin
2016-05-18 1:19 ` William Henney
2016-05-18 3:42 ` Thomas S. Dye
2016-05-18 7:11 ` Karl Voit
2016-05-18 7:10 ` Division of Org documentation: Org manual and Worg (was: Mixing Python2 and Python3 blocks in one file) Karl Voit
2016-05-18 8:10 ` Division of Org documentation: Org manual and Worg Daniele Pizzolli
2016-05-18 9:03 ` Rasmus
2016-05-18 10:08 ` Daniele Pizzolli [this message]
2016-05-18 10:18 ` Rasmus
2016-05-20 17:15 ` Daniele Pizzolli
2016-05-20 18:46 ` Rasmus
2016-05-18 10:18 ` Daniele Pizzolli
2016-05-18 13:45 ` Mixing Python2 and Python3 blocks in one file Ken Mankoff
2016-05-19 3:37 ` William Henney
2016-05-19 13:18 ` Ken Mankoff
2016-05-19 19:21 ` William Henney
2016-05-19 19:32 ` Ken Mankoff
2016-05-19 20:01 ` William Henney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87inybzzzzsmos@me.localhost.invalid \
--to=dan@toel.it \
--cc=bzg@gnu.org \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).