From: Alan W. I. <ir...@be...> - 2014-02-18 22:51:09
|
I am currently using the following method of including documentation strings withing the generated python binding for PLplot: %include swig_documentation.i (where swig_documentation.i has lots of %feature( "docstring", .... commands). That method works fine for ascii documentation, but as soon as I attempted to include UTF-8 strings within that documentation I ran into the following run-time issue with the swig-generated result: __________________________________ Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/software/plplot_svn/HEAD/plplot_allura/bindings/python/plplot.py", line 21, in <module> from plplotc import * File "/home/software/plplot_svn/HEAD/build_dir/bindings/python/plplotc.py", line 3954 SyntaxError: Non-ASCII character '\xe2' in file /home/software/plplot_svn/HEAD/build_dir/bindings/python/plplotc.py on line 3955, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details __________________________________ The first two lines of plplotc.py are # This file was automatically generated by SWIG (http://www.swig.org). # Version 2.0.7 When I manually appended "coding: utf-8" to that first line (appending such a string to the first of second line of the file is the standard method of specifying Python source file encodings according the above URL), then the above run-time error disappeared, and subsquent attempts within python to print out the UTF-8 documentation worked without issues. So to set this up automatically, I could use a "sed" command to append the required string to the first line of the swig-generated file, but that is obviously a hack. Therefore, is there some more official automatic method of generating UTF-8 python documentation with swig? Alan __________________________ Alan W. Irwin Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); the Time Ephemerides project (timeephem.sf.net); PLplot scientific plotting software package (plplot.sf.net); the libLASi project (unifont.org/lasi); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ |