Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'author:': 0.03; 'encoding': 0.05; '"""': 0.07; 'encoded': 0.07; 'subject:file': 0.07; 'utf-8': 0.07; "'')": 0.09; 'except:': 0.09; 'locale': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Python3': 0.09; 'try:': 0.09; 'goodger': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'files.': 0.16; 'skip:# 20': 0.16; 'wrote:': 0.18; 'module': 0.19; 'producing': 0.19; 'command': 0.22; 'import': 0.22; 'header :User-Agent:1': 0.23; 'skip:l 30': 0.24; 'specify': 0.24; 'pass': 0.26; 'header:X-Complaints-To:1': 0.27; 'skip:p 30': 0.29; 'that.': 0.31; 'file': 0.32; 'front': 0.32; 'option': 0.32; 'minimal': 0.33; 'comment': 0.34; 'skip:d 20': 0.34; 'subject:the': 0.34; "i'd": 0.34; 'but': 0.35; 'there': 0.35; 'thanks': 0.36; 'hi,': 0.36; 'should': 0.36; 'to:addr:python- list': 0.38; 'skip:- 10': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'containing': 0.69; 'publisher,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Python3 - temporarily change the file encoding Date: Fri, 21 Mar 2014 19:38:53 +0100 Organization: None References: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p57bda05b.dip0.t-ipconnect.de User-Agent: KNode/4.11.5 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395427150 news.xs4all.nl 2846 [2001:888:2000:d::a6]:47825 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68710 Helmut Jarausch wrote: > Hi, > > my locale is en_US.iso88591 > > But now I'd like to process a restructuredtext file which is encoded in > utf-8. > > rst2html has > > #!/usr/bin/python3.3 > > # $Id: rst2html.py 4564 2006-05-21 20:44:42Z wiemann $ > # Author: David Goodger > # Copyright: This module has been placed in the public domain. > > """ > A minimal front end to the Docutils Publisher, producing HTML. > """ > > try: > import locale > locale.setlocale(locale.LC_ALL, '') > except: > pass > > from docutils.core import publish_cmdline, default_description > > > description = ('Generates (X)HTML documents from standalone > reStructuredText ' > 'sources. ' + default_description) > > publish_cmdline(writer_name='html', description=description) > > -------------- > > Even if I comment out the part containing 'import locale' the utf-8 > encoding of my rst-file is not recognized. > > How can I change this so that rst2html use utf-8 when reading and writing > files. Of course, I don't want to change the docutils package for that. > > Many thanks for a hint, Hm, there is an --input-encoding option that should allow you to specify the encoding on the command line.