title: SQLSTATE[22021]: Character not in repertoire
body: <p>I'm having this problem while seeding my PGSQL Database:</p>
  
  <pre><code>   Illuminate\Database\QueryException  : SQLSTATE[22021]: Character not in repertoire: 7 ERROR:  secuencia de bytes no válida para codificación «UTF8»: 0xe3 0x83 0xe2 (SQL: insert into "races" ("name", "public_name", "members", "updated_at", "created_at") values (harp��a, HarpÃ­a, 23, 2018-04-21 20:30:20, 2018-04-21 20:30:20) returning "id")
  
    at C:\Sandbox\rpgforum\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
      660|         // If an exception occurs when attempting to run a query, we'll format the error
      661|         // message to include the bindings with SQL, which will make this exception a
      662|         // lot more helpful to the developer instead of just the database's errors.
      663|         catch (Exception $e) {
    &gt; 664|             throw new QueryException(
      665|                 $query, $this-&gt;prepareBindings($bindings), $e
      666|             );
      667|         }
      668|
  
    Exception trace:
  
    1   PDOException::("SQLSTATE[22021]: Character not in repertoire: 7 ERROR:  secuencia de bytes no válida para codificación «UTF8»: 0xe3 0x83 0xe2")
        C:\Sandbox\rpgforum\vendor\laravel\framework\src\Illuminate\Database\Connection.php:330
  
    2   PDOStatement::execute()
        C:\Sandbox\rpgforum\vendor\laravel\framework\src\Illuminate\Database\Connection.php:330
  
    Please use the argument -v to see more details.
  </code></pre>
  
  <p>And this is my Seeder's code:</p>
  
  <pre><code>&lt;?php
  
  use Illuminate\Database\Seeder;
  use App\Models\Race;
  
  class RaceTableSeeder extends Seeder
  {
      /**
       * Run the database seeds.
       *
       * @return void
       */
      public function run()
      {
  
        $races = [
          'Humano',
          'Orco',
          'Elfo',
          'Harpía',
          'Enano',
        ];
  
        for ($i = 0; $i &lt; count($races); $i++) {
  
          $race_i = utf8_encode($races[$i]);
  
          $race = Race::create([
            'name' =&gt; strtolower($race_i),
            'public_name' =&gt; $race_i,
            'members' =&gt; mt_rand(10,30),
          ]);
  
        } // for
  
      }
  }
  </code></pre>
  
  <p>My database configuration:</p>
  
  <p><a href="https://i.stack.imgur.com/mcjn9.png" rel="nofollow noreferrer">pgsql database</a></p>
  
  <p>My config.database file config:</p>
  
  <p><a href="https://i.stack.imgur.com/oEzCc.png" rel="nofollow noreferrer">config.database file</a></p>
  
  <p>Is there any solution for this problem? I can find the way to get rid of this problem...</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I just noticed something weird. I got two records in my database:</p>
  
  <p><a href="https://i.stack.imgur.com/KFOiL.png" rel="nofollow noreferrer">database records</a></p>
  
  <p>And both of them have symbols that gave me problem with the <strong>seeder</strong>. Maybe the problem is within the seeders logic? I'm doing the exact same thing I do the whole time with my Laravel/Postgresql projects so i can't find the reason why i can't seed words with accent mark but i can use a simple form to store that kind of information. Any ideas ?</p>