title: Using python to clean up string encoding problems in text files
body: <p>I have a lot of XML documents and filenames for external files that have various forms of text corruption or Mojibake causing data quality problems during import. I've read a number of different posts on StackOverflow on correcting strings, but they fail to really outline how to cleanup text in a systematic way and python's <code>decode</code>, <code>encode</code> don't seem to be helping. How can I recover an XML file and filenames, using Python 2.7, containing characters in the range of Latin-1 (ISO-8859-1) but have mixed encodings generally?</p>