Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to deal with unicode strings - PSS/e 33, Python 2.7, and wxPython

It seems there are various PTI PSS/e python modules that aren't very friendly with unicode formatted strings (psse_env_manager,dyntools, etc). I never had this issue with Rev 32 and the previous bundled python utilities, but the new version is causing some issues with some of my programs. I believe the issue stems from the new wxPython module that is unicode rather than ascii. Anytime I grab text from any one of my GUI's, it converts the text string to unicode format (ie u"string"). Often, I grab a portion of a string from a GUI to define something like a dynamic channel file name. Any time I even grab a portion of the original text and manipulate it, it still formats it as unicode. So if I specify a file in unicode format in psse_env_manager or dyntools, the packages straight up ignore the text and either do nothing (dyntools) or throw an error (psse_env_manager).

So, what I am wondering is if any of you all have ever dealt with this issue? I feel I have two options, both of which are less than ideal:

  1. Convert all text gathered from TextCtrl, ListCtrl, etc boxes into strings (str(object.GetValue())) in every single GUI, or
  2. Go through code and make sure all psse module function calls have an appropriately encoded string (non-unicode) in them

Any ideas?

Is it possible to force ASCII/utf-8 encoding in my programs to disable it ever encoding a string as unicode?

Is it possible to build a function to loop through local/global variables and convert any unicode string to a general string?