I needed to change the default ASCII encoding to Unicode because it removed all accented characters when sending data to my custom stream. While trying to get this to work I found the following problem.

 

Use PythonEngine.SetStdout(), PythonEngine.SetStderr(), PythonEngine.SetStdin () to set your own custom stream. There is a PythonFile wrapper created around the stream with the default encoding specified. Then change the default encoding with sys.setdefaultencoding('utf_16_le'). The encoding of the PythonFile remains the same and it keeps sending data in the old format. I don't know how difficult it is to change this behavior and even if it's possible to change the encoding dynamically.

 

An easy workaround for me is to change the default encoding first and then set the new streams. I'm only using sys.setdefaultencoding('utf_16_le') to specify the default encoding at startup of the PythonEngine. The setting that I want to change is inaccessible: DefaultEncoding is an internal value in SystemState. Maybe it would be a good idea to add this to the Options so that it's possible to directly start the PythonEngine with the desired encoding.

 

-----

 

Something else: it would be nice if the __doc__ of enum's returned all the names of the constants instead of 'no documentation available'.

 

_______________________________________________
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to