Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #68706 > unrolled thread
| Started by | Helmut Jarausch <jarausch@igpm.rwth-aachen.de> |
|---|---|
| First post | 2014-03-21 17:48 +0000 |
| Last post | 2014-03-21 19:38 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
Python3 - temporarily change the file encoding Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2014-03-21 17:48 +0000
Re: Python3 - temporarily change the file encoding Peter Otten <__peter__@web.de> - 2014-03-21 19:38 +0100
| From | Helmut Jarausch <jarausch@igpm.rwth-aachen.de> |
|---|---|
| Date | 2014-03-21 17:48 +0000 |
| Subject | Python3 - temporarily change the file encoding |
| Message-ID | <bp3cc1Fpgg4U1@mid.dfncis.de> |
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 <goodger@python.org>
# 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
[toc] | [next] | [standalone]
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2014-03-21 19:38 +0100 |
| Message-ID | <mailman.8368.1395427150.18130.python-list@python.org> |
| In reply to | #68706 |
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 <goodger@python.org>
> # 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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web