How to convert a software to utf-8
For some of the languages (Japanese, Chinese) it is required to use the utf-8. If you are going to translate a software to these language, you have to convert the software to utf-8. There are a few simple steps for it:
- Change the charset of the page:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- Change the mysql connection type. After the mysql_connect, you should execute the “SET NAMES UTF8” query. For example this way:
function db_connect($sql_host, $sql_user, $sql_password) { $id = mysql_connect($sql_host, $sql_user, $sql_password); db_query("SET NAMES UTF8"); return $id; }
- Change the charset and the collation type of the tables. The following query have to be executed for all of the tables:
ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
For the X-Cart:
$sql_tbl = func_query_column("SHOW TABLES"); foreach($sql_tbl as $tbl) db_query("ALTER TABLE $tbl CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
- Set the locale for the files (it should be inserted in the start up php code, for example in init application script).
setlocale(LC_ALL, 'en_US.UTF-8');
Ans that's all.