title: ucwords and french accented lettres encoding
body: <p>We have a database of Canadian addresses all in CAPS , the client requested that we transform to lower case expect the first letter and the letter after a '-' </p>
  
  <p>So i made this function , but I'm having problem with french accented letters .</p>
  
  <p>When having the file and charset as ISO-88591 It works fine , but when i try to make it UTF-8 it doesn't work anymore .</p>
  
  <p>Example of input : 'damien-claude élanger'
  output           :  Damien-Claude élanger </p>
  
  <p>the é in utf-8 will become � </p>
  
  <pre><code> function cap_letter($string) {
              $lower     = str_split("àáâçèéêë");
              $caps      = str_split("ÀÁÂÇÈÉÊË");
              $letters   = str_split(strtolower($string));
  
              foreach($letters as $code =&gt; $letter) {
                  if($letter === '-' || $letter === ' ') {
                      $position = array_search($letters[$code+1],$lower);
                      if($position !== false) {
                          // test
                          echo $letters[$code+1] . ' == ' . $caps[$position] ; 
                          $letters[$code+1] = $caps[$position];
                      }
                      else {
                          $letters[$code+1] = mb_strtoupper($letters[$code+1]);
                      } 
                  }
              }
              //return ucwords(implode($letters)) ;
              return implode($letters) ;
          }
  </code></pre>
  
  <p>The Other solution i have in mind is to do : ucwords(strtolower($str)) since all the addresses are already in caps so the É will stay É even after applying strtolower .</p>
  
  <p>But then I'll have the problem of having É inside ex : XXXÉXXÉ</p>