I have a string that is an output from Windows console that looks like this when I print it or write to file:
" C o n f i g M a n a g e r E r r o r C o d e = 0 ".
I guess it's something with encoding, but I don't know how to fix it. I've tried:
Code:
mystring = mystring.decode('ascii')
and
Code:
mystring = mystring.encode('ascii', 'ignore')
but none of those worked.
I have also tried simply to replace spaces with nothing:
Code:
mystring = mystring.replace(' ', '')
...but that didn't work too. I guess this string uses two bytes per character (UTF-16?).
All I need is to get ASCII string to check if it begins with: "ConfigManagerErrorCode=", but none of the options I've tried converts my string to that format, so my comparison doesn't work.
Am I right about root cause (encoding) and what can I do to fix this?