OSDN Git Service

Refering to http://sourceforge.jp/projects/nucleus-jp/lists/archive/developers/2011...
authorsakamocchi <sakamocchi@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Wed, 30 Mar 2011 00:11:31 +0000 (00:11 +0000)
committersakamocchi <sakamocchi@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Wed, 30 Mar 2011 00:11:31 +0000 (00:11 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/trunk@1190 1ca29b6e-896d-4ea0-84a5-967f57386b96

utf8/install/index.php
utf8/nucleus/libs/sql/mysql.php
utf8/nucleus/libs/sql/pdo.php

index 38223b1..0ee4aa1 100755 (executable)
@@ -626,7 +626,7 @@ function doInstall() {
 // <add for garble measure>\r
        // 2-2. set DEFAULT CHARSET and COLLATE\r
        $mySqlVer = implode('.', array_map('intval', explode('.', sql_get_server_info())));\r
-       sql_set_charset_jp($charset);\r
+       sql_set_charset_jp($charset,'NAMES');\r
        $collation = ($charset == 'utf8') ? 'utf8_general_ci' : 'ujis_japanese_ci';\r
 // </add for garble measure>*/\r
 \r
index 69e3872..8ae98b7 100755 (executable)
@@ -355,28 +355,37 @@ if (function_exists('mysql_query') && !function_exists('sql_fetch_assoc'))
         * NOTE:        shift_jis is only supported for output. Using shift_jis in DB is prohibited.
         * NOTE:        iso-8859-x,windows-125x if _CHARSET is unset.
         */
-       function sql_set_charset_jp($charset) {
+       function sql_set_charset_jp($charset,$mode = NULL) {
                switch(strtolower($charset)){\r
-                       case 'utf-8':\r
+                       case 'utf-8':
+                       case 'utf8':\r
                                $charset = 'utf8';\r
                                break;\r
-                       case 'euc-jp':\r
+                       case 'euc-jp':
+                       case 'ujis':\r
                                $charset = 'ujis';\r
                                break;\r
                        case 'gb2312':\r
                                $charset = 'gb2312';\r
-                               break;\r
-                       case 'shift_jis':\r
+                               break;
+                       /*\r
+                       case 'shift_jis':
+                       case 'sjis':\r
                                $charset = 'sjis';\r
-                               break;\r
-                       default:\r
+                               break;
+                       */\r
+                       default:
+                               $charset = 'latin1';\r
                                break;\r
                }
                $mySqlVer = implode('.', array_map('intval', explode('.', sql_get_server_info())));
                if (version_compare($mySqlVer, '5.0.7', '>=') && function_exists('mysql_set_charset')) {
                        $res = mysql_set_charset($charset);
                } elseif (version_compare($mySqlVer, '4.1.0', '>=')) {
-                       $res = sql_query("SET CHARACTER SET " . $charset);
+                       $res = ($mode == 'NAMES')
+                               ?sql_query("SET NAMES " . $charset)
+                               :sql_query("SET CHARACTER SET " . $charset)
+                       ;
                }
                return $res;
        }
index 58caa1c..4f9f326 100755 (executable)
@@ -607,28 +607,37 @@ if (!function_exists('sql_fetch_assoc'))
         * NOTE:        shift_jis is only supported for output. Using shift_jis in DB is prohibited.
         * NOTE:        iso-8859-x,windows-125x if _CHARSET is unset.
         */
-       function sql_set_charset_jp($charset) {
+       function sql_set_charset_jp($charset,$mode = NULL) {
                global $MYSQL_HANDLER,$SQL_DBH;
                if (strpos($MYSQL_HANDLER[1], 'mysql') === 0) {
                        switch(strtolower($charset)){\r
-                               case 'utf-8':\r
+                               case 'utf-8':
+                               case 'utf8':\r
                                        $charset = 'utf8';\r
                                        break;\r
-                               case 'euc-jp':\r
+                               case 'euc-jp':
+                               case 'ujis':\r
                                        $charset = 'ujis';\r
                                        break;\r
                                case 'gb2312':\r
                                        $charset = 'gb2312';\r
-                                       break;\r
-                               case 'shift_jis':\r
+                                       break;
+                               /*\r
+                               case 'shift_jis':
+                               case 'sjis':\r
                                        $charset = 'sjis';\r
-                                       break;\r
-                               default:\r
+                                       break;
+                               */\r
+                               default:
+                                       $charset = 'latin1';\r
                                        break;\r
                        }
                        $mySqlVer = implode('.', array_map('intval', explode('.', sql_get_server_info())));
                        if (version_compare($mySqlVer, '4.1.0', '>=')) {
-                               $res = $SQL_DBH->exec("SET CHARACTER SET " . $charset);
+                               $res = ($mode == 'NAMES')
+                                       ?$SQL_DBH->exec("SET NAMES " . $charset)
+                                       :$SQL_DBH->exec("SET CHARACTER SET " . $charset)
+                               ;
                        }
                }
                return $res;