title: recreate encoding mixup in mysql table
body: <p>I have an sql table where a column has <code>utf8_unicode_ci</code> encoding, but the table itself has <code>latin1_swedish_ci</code> encoding (as reported under <code>Row Statistics</code> in <code>Structure</code> tab of <code>phpMyAdmin</code>). </p>
  
  <p>The PHP webapp that accesses the database displays Japanese text correctly, but inside <code>phpMyAdmin</code> everything is <a href="https://en.wikipedia.org/wiki/Mojibake" rel="nofollow noreferrer">mojibake</a>. The webapp (correctly) displays the Japanese text <code>Xで有名な</code>, but in <code>phpMyAdmin</code> it is <code>Xã¦ã‚™æœ‰åãª</code> (<code>hex()</code> output is <code>312E2058C3A3C281C2A6C3A3E2809AE284A2C3A6C593E280B0C3A5C290C28DC3A3C281C2AA</code>). </p>
  
  <p>The app that was used to generate the data in the table is now broken, but I need to add a few new records. How can I recreate the mojibake found in the table?</p>
  
  <p>I tried to reproduce the mojibake with python:</p>
  
  <pre><code>def rev_engineer(utf8):
      mojibake = utf8.encode('utf8').decode('latin1')
      print(mojibake)
  
  rev_engineer('Xで有名な')
  # output:    Xã¦ãæåãª
  # should be: Xã¦ã‚™æœ‰åãª
  </code></pre>
  
  <p>This is obviously very similar, but not quite there. I then tried looping through every possible encoding listed in python's documentation, and encoding/decoding every possible combination, but that did not come up with a match, either. Any idea what I'm missing?</p>