title: using HEX() in Mysql to convert character encoding
body: <p>I have a column with latin1 character encoding.
  Can anyone explain why this happens?</p>
  
  <p>When I run:</p>
  
  <pre><code>SET NAMES utf8;
  SELECT unhex(convert(hex(text) USING utf8)) FROM translation_target
  </code></pre>
  
  <p>I get correctly displaying characters.</p>
  
  <p>When I run:</p>
  
  <pre><code>SET NAMES utf8;
  SELECT text FROM sanus2013_dev1.translation_target;
  </code></pre>
  
  <p>I get the corrupted characters:</p>
  
  <p>So I thought if I ran something like this:</p>
  
  <pre><code>UPDATE translation_target SET text = unhex(convert(hex(text) USING utf8));
  </code></pre>
  
  <p>I would be able to use:</p>
  
  <pre><code>SET NAMES utf8;
  SELECT text FROM sanus2013_dev1.translation_target;
  </code></pre>
  
  <p>and see the correct character encoding. can anyone explain why this doesn't work?</p>
  
  <p>Edit: The Column <code>translation_target</code> has <code>CHARACTER SET latin1</code> with <code>COLLATE latin1_swedish_ci</code></p>
  
  <p>Not sure if this helps but I used an ALTER TABLE COLUMN statement to change the CHARACTER SET to utf8 and the COLLATION to utf8_unicode_ci;</p>
  
  <p>running:</p>
  
  <pre><code>SET NAMES utf8;
  SELECT unhex(convert(hex(text) USING utf8)) FROM translation_target;
  </code></pre>
  
  <p>shows corrupted characters.</p>
  
  <p>When I change the character set and collation back to latin1 it works again.</p>