UTF-8 encoding conversion todo list

This commit is contained in:
2013-10-11 17:30:06 +02:00
parent 5e088b808e
commit a72e2b146a
2 changed files with 49 additions and 5 deletions

View File

@@ -4495,6 +4495,21 @@ class ToolBox
return $asResult;
}
public static function utf8_compliant($sText)
{
if(strlen($sText) == 0) return true;
return (preg_match('/^.{1}/us', $sText, $ar) == 1);
}
/**
* Only works with ISO-8859-1 and UTF-8 encoding
*/
public static function strlen($sText)
{
if(utf8_compliant($sText)) return strlen(utf8_decode($sText));
else return strlen($sText);
}
}
/* Debug */

View File

@@ -168,6 +168,35 @@ if($bUserOk && $sAction!=Databap::EXT_ACCESS)
$oMySqlInstall = new MySqlManager();
$sResult = $oMySqlInstall->getFullInstallQuery();
break;
case 'fix_encoding':
/**
* Procedure (from ISO-8859-1, aka Latin-1)
* - Rss.php : switch ISO <-> UTF : $sFeed = '<?xml version="1.0" encoding="UTF-8" ?>';
* - .htaccess : ajout UTF-8 par défaut : AddDefaultCharset UTF-8 (+check syntax)
* - config.php : Ajouter dans le constructor de Databap :
* - ini_set('default_charset', 'UTF-8');
* - header('Content-Type: text/html; charset=utf-8');
* - config.php : changer tous les ISO en UTF :
* - <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> --> <meta http-equiv="content-type" content="text/html; charset=utf-8" />
* - config.php : Enlever la conversion en UTF8 de jsonExport()
* - config.php : Ajouter $this->oConnection->set_charset('utf8'); dans le constructeur de MySqlManager
* - replace strlen with ToolBox::strlen() --> check the so called mb_* functions
* - Re-encode all tables from database using utf8_encode()
* - Replace all <form> with <form accept-charset="UTF-8">
* - Alter database and change database generation script in MySqlManager :
* - CREATE DATABASE `my_db` CHARACTER SET = utf8 COLLATE = utf8_general_ci;
* - CREATE TABLE `my_table` ([TABLE spec]) CHARACTER SET = utf8 COLLATE = utf8_general_ci;
* - Convert existing database :
* - mysqldump --default_character_set=latin1 -u root -p my_db > my_db.sql
* - iconv -f iso-8859-1 -t utf8 my_db.sql > my_db-utf8.sql
* - sed s/latin1/utf8/ < my_db-utf8.sql > my_db-utf8-final.sql
* - CREATE DATABASE `my_db` CHARACTER SET = utf8 COLLATE = utf8_general_ci;
* - mysql -u root -p my_db < my_db-utf8-final.sql
* - Switch your editor to UTF-8 (search 'encoding' in Eclipse preferences)
* - check http://webcollab.sourceforge.net/unicode.html
* - add mb_* function : sudo apt-get install php-mbstring --> check http://allseeing-i.com/How-to-setup-your-PHP-site-to-use-UTF8
*/
break;
}
}
}
@@ -188,13 +217,13 @@ elseif($bUserOk && $sAction==Databap::EXT_ACCESS)
break;
}
//Restricted actions
if($oDatabap->getUserClearance()==Databap::CLEARANCE_ADMIN)
{
switch($sPage)
//Restricted actions
if($oDatabap->getUserClearance()==Databap::CLEARANCE_ADMIN)
{
switch($sPage)
{
case 'sap_blog': //Syncing SAP BW Blog with database & spreading the news on chat
$sResult = $oDatabap->syncSapBlog();
$sResult = $oDatabap->syncSapBlog();
break;
}
}