Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail From: Helmut Jarausch Newsgroups: comp.lang.python Subject: Python3 - temporarily change the file encoding Date: 21 Mar 2014 17:48:49 GMT Lines: 42 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: news.dfncis.de NalO9lsukRHbwLfLTrYYSgTc+DWaNnC+SrBhZZDL7LtDD1K///bxk+i2sh Cancel-Lock: sha1:97dXkqotR/g6yDdWav91NpWium0= User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Xref: csiph.com comp.lang.python:68706 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, Helmut