From f093987be6ada26a04c70f0bbf840e5b412a9ad1 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Tue, 3 Aug 2004 00:28:55 +0000 Subject: [PATCH] bug 968174: auto-switch to UTF-8 on MySQL 4.1.0+, and default lang is now the non-UTF-8 one --- ChangeLog | 6 ++ libraries/database_interface.lib.php | 11 +++ libraries/select_lang.lib.php | 101 ++++++++++++++------------- 3 files changed, 68 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0dd455b36..2bfec7d38 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,12 @@ phpMyAdmin - Changelog $Id$ $Source$ +2004-08-02 Marc Delisle + * libraries/database_interface.lib.php, /select_lang.lib.php: + bug 968174: now, in MySQL 4.1.0+ we auto-switch the language to + the corresponding -UTF-8 version (if it exists); also, now + the default language is the non-UTF-8 one + 2004-08-02 Michal Čihař * libraries/export/sql.php: Removed unused code. diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php index 9daeb6e5e..f965d4a86 100644 --- a/libraries/database_interface.lib.php +++ b/libraries/database_interface.lib.php @@ -134,6 +134,17 @@ function PMA_DBI_postConnect($link) { } if (PMA_MYSQL_INT_VERSION >= 40100) { + + // If $lang is defined and we are on MySQL >= 4.1.x, + // we auto-switch the lang to its UTF-8 version (if it exists) + if (!empty($GLOBALS['lang']) && (substr($GLOBALS['lang'], -5) != 'utf-8')) { + $lang_utf_8_version = substr($GLOBALS['lang'], 0, strpos($GLOBALS['lang'], '-')) . '-utf-8'; + if (!empty($GLOBALS['available_languages'][$lang_utf_8_version])) { + $GLOBALS['lang'] = $lang_utf_8_version; + $GLOBALS['charset'] = $charset = 'utf-8'; + } + } + $mysql_charset = $GLOBALS['mysql_charset_map'][$GLOBALS['charset']]; if (empty($collation_connection) || (strpos('_', $collation_connection) ? substr($collation_connection, 0, strpos('_', $collation_connection)) : $collation_connection) == $mysql_charset) { PMA_DBI_query('SET NAMES ' . $mysql_charset . ';', $link, PMA_DBI_QUERY_STORE); diff --git a/libraries/select_lang.lib.php b/libraries/select_lang.lib.php index cee7e53f4..cd4d54c52 100644 --- a/libraries/select_lang.lib.php +++ b/libraries/select_lang.lib.php @@ -47,113 +47,114 @@ $lang_path = 'lang/'; * example. * * When there are more than one charset for a language, we put the -utf-8 - * first. + * last because we need the default charset to be non-utf-8 to avoid + * problems on MySQL < 4.1.x if AllowAnywhereRecoding is FALSE. * * For Russian, we put 1251 first, because MSIE does not accept 866 * and users would not see anything. */ $available_languages = array( - 'af-utf-8' => array('af|afrikaans', 'afrikaans-utf-8', 'af'), 'af-iso-8859-1' => array('af|afrikaans', 'afrikaans-iso-8859-1', 'af'), - 'ar-utf-8' => array('ar|arabic', 'arabic-utf-8', 'ar'), + 'af-utf-8' => array('af|afrikaans', 'afrikaans-utf-8', 'af'), 'ar-win1256' => array('ar|arabic', 'arabic-windows-1256', 'ar'), - 'az-utf-8' => array('az|azerbaijani', 'azerbaijani-utf-8', 'az'), + 'ar-utf-8' => array('ar|arabic', 'arabic-utf-8', 'ar'), 'az-iso-8859-9' => array('az|azerbaijani', 'azerbaijani-iso-8859-9', 'az'), - 'bg-utf-8' => array('bg|bulgarian', 'bulgarian-utf-8', 'bg'), + 'az-utf-8' => array('az|azerbaijani', 'azerbaijani-utf-8', 'az'), 'bg-win1251' => array('bg|bulgarian', 'bulgarian-windows-1251', 'bg'), 'bg-koi8-r' => array('bg|bulgarian', 'bulgarian-koi8-r', 'bg'), - 'bs-utf-8' => array('bs|bosnian', 'bosnian-utf-8', 'bs'), + 'bg-utf-8' => array('bg|bulgarian', 'bulgarian-utf-8', 'bg'), 'bs-win1250' => array('bs|bosnian', 'bosnian-windows-1250', 'bs'), - 'ca-utf-8' => array('ca|catalan', 'catalan-utf-8', 'ca'), + 'bs-utf-8' => array('bs|bosnian', 'bosnian-utf-8', 'bs'), 'ca-iso-8859-1' => array('ca|catalan', 'catalan-iso-8859-1', 'ca'), - 'cs-utf-8' => array('cs|czech', 'czech-utf-8', 'cs'), + 'ca-utf-8' => array('ca|catalan', 'catalan-utf-8', 'ca'), 'cs-iso-8859-2' => array('cs|czech', 'czech-iso-8859-2', 'cs'), 'cs-win1250' => array('cs|czech', 'czech-windows-1250', 'cs'), - 'da-utf-8' => array('da|danish', 'danish-utf-8', 'da'), + 'cs-utf-8' => array('cs|czech', 'czech-utf-8', 'cs'), 'da-iso-8859-1' => array('da|danish', 'danish-iso-8859-1', 'da'), - 'de-utf-8' => array('de|german', 'german-utf-8', 'de'), + 'da-utf-8' => array('da|danish', 'danish-utf-8', 'da'), 'de-iso-8859-1' => array('de|german', 'german-iso-8859-1', 'de'), - 'el-utf-8' => array('el|greek', 'greek-utf-8', 'el'), + 'de-utf-8' => array('de|german', 'german-utf-8', 'de'), 'el-iso-8859-7' => array('el|greek', 'greek-iso-8859-7', 'el'), - 'en-utf-8' => array('en|english', 'english-utf-8', 'en'), + 'el-utf-8' => array('el|greek', 'greek-utf-8', 'el'), 'en-iso-8859-1' => array('en|english', 'english-iso-8859-1', 'en'), - 'es-utf-8' => array('es|spanish', 'spanish-utf-8', 'es'), + 'en-utf-8' => array('en|english', 'english-utf-8', 'en'), 'es-iso-8859-1' => array('es|spanish', 'spanish-iso-8859-1', 'es'), - 'et-utf-8' => array('et|estonian', 'estonian-utf-8', 'et'), + 'es-utf-8' => array('es|spanish', 'spanish-utf-8', 'es'), 'et-iso-8859-1' => array('et|estonian', 'estonian-iso-8859-1', 'et'), - 'eu-utf-8' => array('eu|basque', 'basque-utf-8', 'eu'), + 'et-utf-8' => array('et|estonian', 'estonian-utf-8', 'et'), 'eu-iso-8859-1' => array('eu|basque', 'basque-iso-8859-1', 'eu'), - 'fa-utf-8' => array('fa|persian', 'persian-utf-8', 'fa'), + 'eu-utf-8' => array('eu|basque', 'basque-utf-8', 'eu'), 'fa-win1256' => array('fa|persian', 'persian-windows-1256', 'fa'), - 'fi-utf-8' => array('fi|finnish', 'finnish-utf-8', 'fi'), + 'fa-utf-8' => array('fa|persian', 'persian-utf-8', 'fa'), 'fi-iso-8859-1' => array('fi|finnish', 'finnish-iso-8859-1', 'fi'), - 'fr-utf-8' => array('fr|french', 'french-utf-8', 'fr'), + 'fi-utf-8' => array('fi|finnish', 'finnish-utf-8', 'fi'), 'fr-iso-8859-1' => array('fr|french', 'french-iso-8859-1', 'fr'), - 'gl-utf-8' => array('gl|galician', 'galician-utf-8', 'gl'), + 'fr-utf-8' => array('fr|french', 'french-utf-8', 'fr'), 'gl-iso-8859-1' => array('gl|galician', 'galician-iso-8859-1', 'gl'), + 'gl-utf-8' => array('gl|galician', 'galician-utf-8', 'gl'), 'he-iso-8859-8-i' => array('he|hebrew', 'hebrew-iso-8859-8-i', 'he'), 'hi-utf-8' => array('hi|hindi', 'hindi-utf-8', 'hi'), - 'hr-utf-8' => array('hr|croatian', 'croatian-utf-8', 'hr'), 'hr-win1250' => array('hr|croatian', 'croatian-windows-1250', 'hr'), 'hr-iso-8859-2' => array('hr|croatian', 'croatian-iso-8859-2', 'hr'), - 'hu-utf-8' => array('hu|hungarian', 'hungarian-utf-8', 'hu'), + 'hr-utf-8' => array('hr|croatian', 'croatian-utf-8', 'hr'), 'hu-iso-8859-2' => array('hu|hungarian', 'hungarian-iso-8859-2', 'hu'), - 'id-utf-8' => array('id|indonesian', 'indonesian-utf-8', 'id'), + 'hu-utf-8' => array('hu|hungarian', 'hungarian-utf-8', 'hu'), 'id-iso-8859-1' => array('id|indonesian', 'indonesian-iso-8859-1', 'id'), - 'it-utf-8' => array('it|italian', 'italian-utf-8', 'it'), + 'id-utf-8' => array('id|indonesian', 'indonesian-utf-8', 'id'), 'it-iso-8859-1' => array('it|italian', 'italian-iso-8859-1', 'it'), - 'ja-utf-8' => array('ja|japanese', 'japanese-utf-8', 'ja'), + 'it-utf-8' => array('it|italian', 'italian-utf-8', 'it'), 'ja-euc' => array('ja|japanese', 'japanese-euc', 'ja'), 'ja-sjis' => array('ja|japanese', 'japanese-sjis', 'ja'), + 'ja-utf-8' => array('ja|japanese', 'japanese-utf-8', 'ja'), 'ko-euc-kr' => array('ko|korean', 'korean-euc-kr', 'ko'), 'ko-utf-8' => array('ko|korean', 'korean-utf-8', 'ko'), 'ka-utf-8' => array('ka|georgian', 'georgian-utf-8', 'ka'), - 'lt-utf-8' => array('lt|lithuanian', 'lithuanian-utf-8', 'lt'), 'lt-win1257' => array('lt|lithuanian', 'lithuanian-windows-1257', 'lt'), - 'lv-utf-8' => array('lv|latvian', 'latvian-utf-8', 'lv'), + 'lt-utf-8' => array('lt|lithuanian', 'lithuanian-utf-8', 'lt'), 'lv-win1257' => array('lv|latvian', 'latvian-windows-1257', 'lv'), - 'ms-utf-8' => array('ms|malay', 'malay-utf-8', 'ms'), + 'lv-utf-8' => array('lv|latvian', 'latvian-utf-8', 'lv'), 'ms-iso-8859-1' => array('ms|malay', 'malay-iso-8859-1', 'ms'), - 'nl-utf-8' => array('nl|dutch', 'dutch-utf-8', 'nl'), + 'ms-utf-8' => array('ms|malay', 'malay-utf-8', 'ms'), 'nl-iso-8859-1' => array('nl|dutch', 'dutch-iso-8859-1', 'nl'), - 'no-utf-8' => array('no|norwegian', 'norwegian-utf-8', 'no'), + 'nl-utf-8' => array('nl|dutch', 'dutch-utf-8', 'nl'), 'no-iso-8859-1' => array('no|norwegian', 'norwegian-iso-8859-1', 'no'), - 'pl-utf-8' => array('pl|polish', 'polish-utf-8', 'pl'), + 'no-utf-8' => array('no|norwegian', 'norwegian-utf-8', 'no'), 'pl-iso-8859-2' => array('pl|polish', 'polish-iso-8859-2', 'pl'), - 'pt-br-utf-8' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-utf-8', 'pt-BR'), - 'pt-br-iso-8859-1' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-iso-8859-1', 'pt-BR'), - 'pt-utf-8' => array('pt|portuguese', 'portuguese-utf-8', 'pt'), + 'pl-utf-8' => array('pl|polish', 'polish-utf-8', 'pl'), + 'ptbr-iso-8859-1' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-iso-8859-1', 'pt-BR'), + 'ptbr-utf-8' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-utf-8', 'pt-BR'), 'pt-iso-8859-1' => array('pt|portuguese', 'portuguese-iso-8859-1', 'pt'), - 'ro-utf-8' => array('ro|romanian', 'romanian-utf-8', 'ro'), + 'pt-utf-8' => array('pt|portuguese', 'portuguese-utf-8', 'pt'), 'ro-iso-8859-1' => array('ro|romanian', 'romanian-iso-8859-1', 'ro'), + 'ro-utf-8' => array('ro|romanian', 'romanian-utf-8', 'ro'), 'ru-win1251' => array('ru|russian', 'russian-windows-1251', 'ru'), - 'ru-utf-8' => array('ru|russian', 'russian-utf-8', 'ru'), 'ru-cp-866' => array('ru|russian', 'russian-cp-866', 'ru'), 'ru-koi8-r' => array('ru|russian', 'russian-koi8-r', 'ru'), - 'sk-utf-8' => array('sk|slovak', 'slovak-utf-8', 'sk'), + 'ru-utf-8' => array('ru|russian', 'russian-utf-8', 'ru'), 'sk-iso-8859-2' => array('sk|slovak', 'slovak-iso-8859-2', 'sk'), 'sk-win1250' => array('sk|slovak', 'slovak-windows-1250', 'sk'), - 'sl-utf-8' => array('sl|slovenian', 'slovenian-utf-8', 'sl'), + 'sk-utf-8' => array('sk|slovak', 'slovak-utf-8', 'sk'), 'sl-iso-8859-2' => array('sl|slovenian', 'slovenian-iso-8859-2', 'sl'), 'sl-win1250' => array('sl|slovenian', 'slovenian-windows-1250', 'sl'), - 'sq-utf-8' => array('sq|albanian', 'albanian-utf-8', 'sq'), + 'sl-utf-8' => array('sl|slovenian', 'slovenian-utf-8', 'sl'), 'sq-iso-8859-1' => array('sq|albanian', 'albanian-iso-8859-1', 'sq'), - 'sr-lat-utf-8' => array('sr[-_]lat|serbian latin', 'serbian_latin-utf-8', 'sr-lat'), - 'sr-lat-win1250' => array('sr[-_]lat|serbian latin', 'serbian_latin-windows-1250', 'sr-lat'), - 'sr-utf-8' => array('sr|serbian', 'serbian_cyrillic-utf-8', 'sr'), - 'sr-win1251' => array('sr|serbian', 'serbian_cyrillic-windows-1251', 'sr'), - 'sv-utf-8' => array('sv|swedish', 'swedish-utf-8', 'sv'), + 'sq-utf-8' => array('sq|albanian', 'albanian-utf-8', 'sq'), + 'srlat-win1250' => array('sr[-_]lat|serbian latin', 'serbian_latin-windows-1250', 'sr-lat'), + 'srlat-utf-8' => array('sr[-_]lat|serbian latin', 'serbian_latin-utf-8', 'sr-lat'), + 'srcyr-win1251' => array('sr|serbian', 'serbian_cyrillic-windows-1251', 'sr'), + 'srcyr-utf-8' => array('sr|serbian', 'serbian_cyrillic-utf-8', 'sr'), 'sv-iso-8859-1' => array('sv|swedish', 'swedish-iso-8859-1', 'sv'), - 'th-utf-8' => array('th|thai', 'thai-utf-8', 'th'), + 'sv-utf-8' => array('sv|swedish', 'swedish-utf-8', 'sv'), 'th-tis-620' => array('th|thai', 'thai-tis-620', 'th'), - 'tr-utf-8' => array('tr|turkish', 'turkish-utf-8', 'tr'), + 'th-utf-8' => array('th|thai', 'thai-utf-8', 'th'), 'tr-iso-8859-9' => array('tr|turkish', 'turkish-iso-8859-9', 'tr'), - 'uk-utf-8' => array('uk|ukrainian', 'ukrainian-utf-8', 'uk'), + 'tr-utf-8' => array('tr|turkish', 'turkish-utf-8', 'tr'), 'uk-win1251' => array('uk|ukrainian', 'ukrainian-windows-1251', 'uk'), - 'zh-tw-utf-8' => array('zh[-_]tw|chinese traditional', 'chinese_traditional-utf-8', 'zh-TW'), - 'zh-tw-big5' => array('zh[-_]tw|chinese traditional', 'chinese_traditional-big5', 'zh-TW'), - 'zh-utf-8' => array('zh|chinese simplified', 'chinese_simplified-utf-8', 'zh'), - 'zh-gb2312' => array('zh|chinese simplified', 'chinese_simplified-gb2312', 'zh') + 'uk-utf-8' => array('uk|ukrainian', 'ukrainian-utf-8', 'uk'), + 'zhtw-big5' => array('zh[-_]tw|chinese traditional', 'chinese_traditional-big5', 'zh-TW'), + 'zhtw-utf-8' => array('zh[-_]tw|chinese traditional', 'chinese_traditional-utf-8', 'zh-TW'), + 'zh-gb2312' => array('zh|chinese simplified', 'chinese_simplified-gb2312', 'zh'), + 'zh-utf-8' => array('zh|chinese simplified', 'chinese_simplified-utf-8', 'zh') );