From: <bc...@wo...> - 2001-11-26 15:55:11
|
[dman] >On one of my Debian woody boxes jythonc stopped working a while ago. >Jython still worked, but running 'jythonc' would give no output. I >have now solved the problem, but I think it involves a bug in jython. > >I traced through how jythonc was supposed to be run -- it is pretty >straightforward : jython is run with >/usr/share/jython/Tools/jythonc/jythonc.py as the first argument (and >any other arguments are passed to the script). I added a print to the >top of jythonc.py, but it wouldn't get printed. It was really strange >because I could create a "hello world" program and it would work. As >I took a deeper look, looking at main.py I noticed that there were >several Form Feed characters in it. I removed those (from the other >source files as well) but those had no bearing on my problem. (I >don't think there is a reason to have form feeds anyways, unless >perhaps one intends to "cat <source> > /dev/lp0" with an old printer) >The solution, as it turned out, was to open each of the source files, >convert them to utf-8 and save them again. > >What difference does it make to jython whether a (python) source file >is saved in latin1 or utf-8? In any case, I think it is a gross error >to simply terminate with no message when encountering a file that it >doesn't like. Sure. Normally jython doesn't. So what is special about woody? >I started the conversion to utf-8 from main.py, I have now removed the latin-1 copyright character in the CVS version. >... >The interesting thing about jythonc's source files is that they all >have the copyright symbol in a comment at the top of the file. In >'latin1' this is character 0xa9. The python source files is read as text files with a InputStreamReader using the default encoding for the platform. Normally that is a good way to read text files but a sideeffect is that python source programs with non-ascii characters isn't portable to other platforms with a different encoding. I don't know what the cause is, but these experiments might help shed light on it. What file encoding is used in your setup of woody? >>> import java >>> java.lang.System.getProperty("file.encoding") 'Cp1252' >>> Whatever the encoding used is, it may be unable to handle 0xA9 correctly: >>> from java import io >>> s = io.FileOutputStream("foo") >>> s.write("\xA9") >>> s.close() >>> s = io.FileReader("foo") >>> print hex(s.read()) 0xa9 >>> s.close() >>> >I use (g)vim 6.0 as my editor. As >you may already know it has two variables, 'enc' and 'fenc'. You could change the file encoding of the source files. You would then have to change the encoding used by java as well. But I strongly doubt that you want to go there. If latin1 is suitable for your country and language, stick with that. regards, finn |