title: mysql comparison and encoding
body: <p>I have a problem with MySQL here, it's quite strange actually... it's a real headbreak, I've been trying a lot of things, sticking some COLLATE, CAST, CONVERT,... but nothing, maybe i'm not doing it the right way, but I'm really lost here.</p>
  
  <p>If some pro has a tip ;) here is my problem:</p>
  
  <pre><code>SELECT col FROM tabl LIMIT 0,1 
  </code></pre>
  
  <p>returns: helloworld01 </p>
  
  <pre><code>CASE WHEN((SELECT col FROM tabl LIMIT 0,1) = 'helloworld_01') THEN 'ok' ELSE 'ko' END
  </code></pre>
  
  <p>returns: ok</p>
  
  <pre><code>CASE WHEN(SUBSTR('helloworld_01',1,1) = 'h') THEN 'ok' ELSE 'ko' END
  </code></pre>
  
  <p>returns: ok</p>
  
  <p>BUT and this is where it get strange</p>
  
  <pre><code> CASE WHEN(SUBSTR((SELECT col FROM tabl LIMIT 0,1),1,1) = 'h') 
   THEN 'ok' ELSE 'ko' END
  </code></pre>
  
  <p>returns: ko</p>
  
  <p>after manually checking each letter i found that the result is quite strange ... numbers and letters in correct order but each character isn't the one supposed to be ... i get something like lsuejwodhb_65
   .... but do not change at each request ... and they do not matche their CHAR code either .... </p>