On linux, at least, what you're looking for is GNU "recode"...
On Oct 13, 1:49 pm, "Bruce Eckel" <[EMAIL PROTECTED]> wrote:
> For what it's worth, here's one way to change encodings. I'm just thrashing
> around here so there may be a more elegant way:
> #! /usr/bin/env python
> import os, codecs
>
> for root, dirs, files in os.walk("book"):
> for f in files:
> if f.endswith(".txt"):
> path = os.path.join(root, f)
> fileObj = codecs.open(path, "r", "latin-1")
> u = fileObj.read() # Returns a Unicode string from the latin-1
> bytes in the file
> file(path, 'w').write(u.encode("utf-8", 'replace'))
>
>
>
> On Mon, Oct 13, 2008 at 11:09 AM, Bruce Eckel <[EMAIL PROTECTED]> wrote:
> > Still trying to understand the issue: Sphinx itself will not handle
> > anything but utf-8? As you say, a bit muddy -- the above looks like a
> > strategy pattern which suggests that Sphinx might be able to handle more
> > than one kind of encoding. But perhaps other code within Sphinx prevents
> > this?
> > Sorry for the confused newbie questions, everyone. Just trying to get a
> > handle on all this.
>
> > On Mon, Oct 13, 2008 at 10:26 AM, Yarko T <[EMAIL PROTECTED]> wrote:
>
> >> On Mon, Oct 13, 2008 at 11:17 AM, Yarko T <[EMAIL PROTECTED]> wrote:
>
> >>> this is a bit muddy to me:
> >>> ........
>
> >>> encoding = options.get('encoding', 'utf-8')
> >>> try:
> >>> f = codecs.open(fn, 'r', encoding)
> >>> text = f.read()
> >>> f.close()
>
> >>> So I'll guess you can use this to filter your source files (?).
>
> >>> Regards,
> >>> Yarko
>
> >> ....that is to say, this strategy - create a filter based on this simple
> >> I/O pattern, and run through your source tree, letting codecs do the
> >> conversion...
>
> >>> On Mon, Oct 13, 2008 at 12:55 AM, Bruce Eckel <[EMAIL PROTECTED]>wrote:
>
> >>>> OK, the next question is how to make the change. The only thing I found
> >>>> in the docs was a reference to the conf.py file, but changing that (to,
> >>>> for
> >>>> example, latin-1 which should take care of it) doesn't have any effect.
> >>>> Thanks for any help.
>
> >>>> On Sun, Oct 12, 2008 at 8:20 PM, Peter Hoffmann <[EMAIL PROTECTED]>wrote:
>
> >>>>> The problem is the word Façade. As far as I know sphinx only supports
> >>>>> utf-8 file encodings, but your file changeInterface/
> >>>>> changeInterface.txt (and some others too) use non ascii characters
> >>>>> with 8859 file encoding.
>
> >>>>> If you change the file encoding to utf-8 and try again, it should work
> >>>>> (beside some other errors due to wrong length of underline for
> >>>>> headings).
>
> >>>>> Regards Peter
>
> >>>>> On 13 Okt., 03:10, "Bruce Eckel" <[EMAIL PROTECTED]> wrote:
> >>>>> > I used sphinx-quickstart to get started, and I think I followed the
> >>>>> > instructions correctly. I've attached my project, which gives me the
> >>>>> > following error:
> >>>>> > $ make html
> >>>>> > mkdir -p _build/html _build/doctrees
> >>>>> > sphinx-build -b html -d _build/doctrees . _build/html
> >>>>> > Sphinx v0.4.3, building html
> >>>>> > trying to load pickled env... not found
> >>>>> > building [html]: targets for 20 source files that are out of date
> >>>>> > updating environment: 20 added, 0 changed, 0 removed
> >>>>> > reading... appFrameworks/appFrameworks
> >>>>> changeInterface/changeInterface
> >>>>> > Exception occurred:
> >>>>> > File "C:\Python\Lib\site-packages\docutils\io.py", line 124, in
> >>>>> > decode error_details))
> >>>>> > UnicodeError: Unable to decode input data. Tried the following
> >>>>> encodings:
> >>>>> > 'utf-8'.
> >>>>> > (UnicodeDecodeError: 'utf8' codec can't decode bytes in position
> >>>>> 432-434:
> >>>>> > invalid data)
> >>>>> > The full traceback has been saved in
> >>>>> > c:\docume~1\bruce\locals~1\temp\sphinx-err-o_ecqz.log, if you want to
> >>>>> report
> >>>>> > the issue to the author.
> >>>>> > Please also report this if it was a user error, so that a better
> >>>>> error
> >>>>> > message c
> >>>>> > an be provided next time.
> >>>>> > Send reports to [EMAIL PROTECTED] Thanks!
> >>>>> > make: *** [html] Error 1
>
> >>>>> > --
> >>>>> > Bruce Eckel
>
> >>>>> > book.zip
> >>>>> > 267KAnzeigenHerunterladen
>
> >>>> --
> >>>> Bruce Eckel
>
> > --
> > Bruce Eckel
>
> --
> Bruce Eckel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sphinx-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sphinx-dev?hl=en
-~----------~----~----~----~------~----~------~--~---