changing unicode characters in a module There are hundreds of records in a database that are in windows-1256 charset, I want to read these data and convert them to utf8 then insert them in a new table, to read these data I need to change the MySQL unicode to latin1 and convert the data to utf8. from this link I successfully did this. 
Now I need to insert these data into database and their charset must be utf8, the problem is $database variable in settings.php have this configuration

$databases = array (
  'default' =&gt; 
  array (
    'default' =&gt; 
    array (
      'database' =&gt; 'DB_NAME',
      'username' =&gt; 'PASSWORD',
      'password' =&gt; 'PASSWORD',
      'host' =&gt; 'localhost',
      'port' =&gt; '',
      'driver' =&gt; 'mysql',
      'prefix' =&gt; '',
      'collation' =&gt; 'latin1_general_ci',
      'pdo' =&gt; array(
            PDO::MYSQL_ATTR_INIT_COMMAND =&gt; "SET NAMES latin1",
      )
    ),
  ),
);


and in database/mysql/database.inc line 57 changed to this:

if (!empty($connection_options['collation'])) {
  $this-&gt;exec('SET NAMES latin1 COLLATE ' . $connection_options['collation']);
}


so because of this new database configuration, insertion the converted records (to utf8) doesn't provide the desire result (because MySQL is latin1 now), I need to reset the database configuration to its origin just before inserting the data. how do I can do this?



UPDATE:

the only solution I have found so far, is to create another database in utf8 and using external connection move the data into there !!!
1) run query 
ALTER DATABASE DB_NAME DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci 
on your data base

2) change line 


  'collation' => 'latin1_general_ci'


in settings.php to 


  'collation' => 'utf8_general_ci'


and line 


  PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES latin1"


to


  PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"