On Mon, Jan 08, 2007 at 07:25:12PM +0100, Georg Baum wrote: > Am Montag, 8. Januar 2007 04:03 schrieb [EMAIL PROTECTED]: > > Author: forenr > > Date: Mon Jan 8 04:03:12 2007 > > New Revision: 16592 > > > > URL: http://www.lyx.org/trac/changeset/16592 > > Log: > > Fix problem with filename encoding in python script for graphics > conversion > > > > * src/graphics/GraphicsConverter.C > > (build_script): convert the input filename from utf8 to the default > > locale encoding as it hopefully corresponds to the filesystem encoding. > > Great! It would be nice if you could check whether we need something like > this in other python scripts as well.
I tried to have a quick look around, but did not make my mind (actually, I had no time to further investigate this issue). > What I do not understand: Why does python not set the right encoding for > us? There might be reasons to access files with the raw encoded string, > but if python already knows that it is an unicode string why does it not > convert it to the right encoding? Even if a given encoding is specified for a file, python treats a string such as "hello" as a sequence of bytes, not as an unicode string. These byte strings must be explicitly converted to unicode, and only then they may be converted to other encodings. I also tried to use the right encoding for the filename (even if it was different from the stated encoding for the file) and that worked, too. I wondered whether to take the approach of always using the filesystem encoding when writing a filename to a python file, but then decided to do it this way, which is what is recommended here: http://www.onlamp.com/pub/a/python/excerpt/pythonckbk_chap1/index.html -- Enrico