From d5ed8a1fc4fc73fa0e96513a0b72538dbd57c2b5 Mon Sep 17 00:00:00 2001 From: james Date: Wed, 9 Jun 2010 15:11:14 +0000 Subject: [PATCH] Modified version of update 173 to handle special windows characters --- db/db.update.173.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/db/db.update.173.php b/db/db.update.173.php index b69da33..5dd9f9d 100644 --- a/db/db.update.173.php +++ b/db/db.update.173.php @@ -58,6 +58,7 @@ function db_update_173_post(){ ) ... + Keys uses the same arrangement for tracking the key fields in the tables Now we need to run through those tables one at a time and convert them */ $totalFailCount = 0; @@ -80,12 +81,14 @@ function db_update_173_post(){ $query .= " FROM $tableName"; // fetch all of those values + mysql_query("SET NAMES latin1"); $updates = array(); $data = mysql_query($query); while($record = mysql_fetch_array($data)){ $updates[] = $record; } -// mysql_query("SET NAMES utf8"); + mysql_query("SET NAMES utf8"); + echo "Changing default character set on table \"$tableName\": "; // now we have the data - let's convert the table @@ -99,7 +102,6 @@ function db_update_173_post(){ $totalFailCount ++; } }else{ - //echo "ALTER TABLE `$tableName` DEFAULT CHARACTER SET 'utf8';\n"; echo " success\n"; } @@ -117,9 +119,9 @@ function db_update_173_post(){ }else{ $useComma = true; } - $newValue = mb_convert_encoding($fieldValue, "UTF-8", "iso-8859-1"); + $newValue = iconv("windows-1252", "iso-8859-1//TRANSLIT", $fieldValue); + $newValue = iconv("iso-8859-1", 'UTF-8//TRANSLIT', $newValue); $query .= " `" . $fieldName . "` = '" . mysql_real_escape_string($newValue) . "'"; - //$query .= sprintf(" `%s` = '%s'", $fieldName, mysql_real_escape_string($newValue)); } $query .= " WHERE "; for($n = 0; $n < count($keys[$tableName]); $n++){