title: How best to convert mixed-encoded mailbox file to UTF-8?
body: <p>I have an .mbox mailbox file containing thousands of email messages in different languages, variously encoded in ASCII, ISO-8859-1 and UTF-8. I want to "flatten" the file into UTF-8.</p>
  
  <p>My first effort was to loop through the file, doing a <code>file -b --mime-encoding</code> on each character, and an <code>iconv -f ISO-8859-1 -t UTF-8</code> on any character detected as ISO-8859-1. I understand that UTF-8 is a superset of ASCII, so only ISO-8859-1 needs conversion.</p>
  
  <p>This took forever and for some reason did not work as expected. Problem characters remained.</p>
  
  <p>Is there an obvious way of doing this in a one-liner, or will it be necessary to resort to <code>formail</code> to convert the file messages by message?</p>