title: How to fix UTF8 inside laravel Seed?
body: <p>I'm trying to import an old DB inside my new laravel project. To make things simple, some of the entries were made through the French version of MS Office and the old website was dealing with those encoding really poorly.</p>
  
  <p>There are apostrophes, accents, strange characters word has to make the texts prettier... </p>
  
  <ul>
  <li><p>On the original files, enca tells me "Unknown encoding"</p></li>
  <li><p>I tried python-chardet and it tells me ISO-8859-7 (.88)</p></li>
  <li><p>I tried iconv with ISO-8859-{1-15}, no good came out of it.</p></li>
  <li><p>I resolved myself on booting up my windows and using Notepad ++ to
  convert the file to UTF8-no-bom. Which ended up having enca
  recognizing UTF-8 but literally destroyed half the caracters.</p></li>
  <li><p>I've tried adding the 3 UTF8 following lines in <code>/etc/mysql/my.cnf</code>
  and  every test were done with and without them (commenting /
  un-commenting), so far it hasn't changed anything.</p>
  
  <p><code>collation-server = utf8_unicode_ci
  init-connect='SET NAMES utf8'
  character-set-server = utf8</code></p></li>
  <li><p>I made sure that those 2 lines were in the mysql array of <code>/app/config/database.php</code></p>
  
  <p><code>'charset'   =&gt; 'utf8',
  'collation' =&gt; 'utf8_unicode_ci',</code></p></li>
  </ul>
  
  <p>Currently the seed file (simplified) looks like this : </p>
  
  <pre><code>&lt;?php
  // app/database/seeds/ArticlesTableSeeder.php
  
  class ArticlesTableSeeder extends Seeder
  {
      public function run()
      {
          DB::table('articles')-&gt;delete();
              Articles::create(array(
                       // ’ != ', I could do a str_replace but
                       // there are many similar characters spread everywhere
                      'test1'       =&gt; utf8_decode("l’année"), 
                      'test2'       =&gt; "l’année", 
                      'test3'       =&gt; "l’année"
                      ));
  
      }
  
  }
  </code></pre>
  
  <p>Once seeded, this is what I get in my database :</p>
  
  <pre><code>test1 &gt; l?ann
  test2 &gt; lâannÃ©e
  test3 &gt; lâannÃ©e // Same as test2
  </code></pre>
  
  <p>I made this test output :</p>
  
  <pre><code>print_r(utf8_encode($test1));
  // l?ann
  print_r(utf8_decode($test2));
  // l?année
  print_r($test3);
  // lâ€™annÃ©e
  </code></pre>
  
  <p>I'm at this point where I've spent more time on this problem than I should have but I'm not the kind of person who simply gives up. I'm not sure of what to do so I figured it was time to ask.</p>