diff --git a/ChangeLog b/ChangeLog index 6611b7712..9422d6817 100755 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,14 @@ $Source$ in an "UPDATE" statement. * lang/japanese-*: updated thanks to "luc". * sql.php3: use "[[:space:]]" class inside all regular expressions. + * db_details.php3, lines 585-589 & 729-734; Documentation.html; + ldi_check.php3, lines 32-35; ldi_table.php3, lines 60-69; + read_dump.php3, lines 279-287; sql.php3, lines 267-271; tbl_dump.php3; + tbl_properties.php3; lang/japanese-*; + libraries/common.lib.php3, lines 1026-1034; + libraries/kanji-encoding.lib.php3: japanese kanji encoding conversion + feature thanks to Yukihiro Kawada aka "luc" + . 2002-02-23 Marc Delisle * swedish updates thanks to Bj顤n T. Hallberg diff --git a/Documentation.html b/Documentation.html index 55706ad85..2c596576c 100755 --- a/Documentation.html +++ b/Documentation.html @@ -1076,10 +1076,11 @@

- I have problems with mysql.user field names. + I have problems with mysql.user field names.
- In older MySQL versions, the User and Password fields were named user and - password. Please modify your field names to align with current standards. + In older MySQL versions, the User and Password fields + were named user and password. Please modify your field + names to align with current standards.

[Configuration]

@@ -1590,6 +1591,8 @@ code since version 2.1.0: for multiple table printviews. - Garvin Hicking <hicking at faktor-e.de> who builds the patch for vertical display of table rows. +- Yukihiro Kawada <kawada at den.fujifilm.co.jp> for the japanese kanji + encoding conversion feature. - Piotr Roszatycki <d3xter at users.sourceforge.net> and Dan Wilson, for the Cookie authentication mode. - Axel Sander <n8falke at users.sourceforge.net> for the table diff --git a/db_details.php3 b/db_details.php3 index 819bf8807..b4790d791 100755 --- a/db_details.php3 +++ b/db_details.php3 @@ -582,6 +582,11 @@ if ($cfgBookmark['db'] && $cfgBookmark['table']) { echo ' ' . "\n"; } } + +// Encoding setting form appended by Y.Kawada +if (function_exists('PMA_set_enc_form')) { + echo PMA_set_enc_form(' '); +} ?> @@ -721,6 +726,12 @@ if ($num_tables > 0) { } } echo "\n"; + + // Encoding setting form appended by Y.Kawada + if (function_exists('PMA_set_enc_form')) { + echo '
' . "\n" + . PMA_set_enc_form(' '); + } ?> diff --git a/lang/japanese-euc.inc.php3 b/lang/japanese-euc.inc.php3 index 606a4cfd8..5d2655aa5 100644 --- a/lang/japanese-euc.inc.php3 +++ b/lang/japanese-euc.inc.php3 @@ -344,5 +344,9 @@ $strYes = ' $strZip = '"zip今木月"'; +// japanese only +$strXkana = '蟈剩市瓜尺庍晶允月'; // convert to X208-kana +$strEncto = '巨件戊□犯奴件弘尺庍晶允月'; // encoding convert + // To translate ?> diff --git a/lang/japanese-sjis.inc.php3 b/lang/japanese-sjis.inc.php3 index 0264ade8a..8bf40b77e 100644 --- a/lang/japanese-sjis.inc.php3 +++ b/lang/japanese-sjis.inc.php3 @@ -344,5 +344,9 @@ $strYes = ' $strZip = '"zip"'; +// japanese only +$strXkana = 'SpJi'; // convert to X208-kana +$strEncto = 'GR[fBO'; // encoding convert + // To translate ?> diff --git a/ldi_check.php3 b/ldi_check.php3 index 92e17efaf..97c2c9682 100755 --- a/ldi_check.php3 +++ b/ldi_check.php3 @@ -29,6 +29,10 @@ if (isset($btnLDI) && ($textfile != 'none')) { $replace = ''; } + // Kanji encoding convert appended by Y.Kawada + if (function_exists('PMA_kanji_file_conv')) { + $textfile = PMA_kanji_file_conv($textfile, $knjenc, $xkana); + } // Formats the data posted to this script $textfile = PMA_sqlAddslashes($textfile); if (get_magic_quotes_gpc()) { diff --git a/ldi_table.php3 b/ldi_table.php3 index 1e335ef01..8454f8ad5 100755 --- a/ldi_table.php3 +++ b/ldi_table.php3 @@ -57,6 +57,16 @@ require('./header.inc.php3'); +' . "\n" + . ' Kanji encoding convert' . "\n" + . ' ' . "\n" + . PMA_set_enc_form(' ') + . ' ' . "\n" + . ' ' . "\n"; +?> diff --git a/libraries/common.lib.php3 b/libraries/common.lib.php3 index a1443a0de..bc6d72e8e 100644 --- a/libraries/common.lib.php3 +++ b/libraries/common.lib.php3 @@ -1024,5 +1024,14 @@ window.parent.frames['nav'].location.replace(''); return strftime($date, $timestamp); } // end of the 'PMA_localisedDate()' function + + // Kanji encoding convert feature appended by Y.Kawada (2002/2/20) + if (PMA_PHP_INT_VERSION >= 40006 + && @function_exists('mb_convert_encoding') + && strpos(' ' . $lang, 'ja-') + && file_exists('./libraries/kanji-encoding.lib.php3')) { + include('./libraries/kanji-encoding.lib.php3'); + } // end if + } // $__PMA_COMMON_LIB__ ?> diff --git a/libraries/kanji-encoding.lib.php3 b/libraries/kanji-encoding.lib.php3 new file mode 100644 index 000000000..49081c558 --- /dev/null +++ b/libraries/kanji-encoding.lib.php3 @@ -0,0 +1,152 @@ + + */ +if (!defined('PMA_ENCODING_LIB_INCLUDED')) { + define('PMA_ENCODING_LIB_INCLUDED', 1); + + /** + * Gets the php internal encoding codes and sets the available encoding + * codes list + * 2002/1/4 by Y.Kawada + * + * @global string the current encoding code + * @global string the available encoding codes list + * + * @return boolean always true + */ + function PMA_internal_enc_check() { + global $internal_enc, $enc_list; + + $internal_enc = mb_internal_encoding(); + if ($internal_enc == 'EUC-JP') { + $enc_list = 'ASCII,EUC-JP,SJIS,JIS'; + } else { + $enc_list = 'ASCII,SJIS,EUC-JP,JIS'; + } + + return TRUE; + } // end of the 'PMA_internal_enc_check' function + + + /** + * Reverses SJIS & EUC-JP position in the encoding codes list + * 2002/1/4 by Y.Kawada + * + * @global string the available encoding codes list + * + * @return boolean always true + */ + function PMA_change_enc_order() { + global $enc_list; + + $p = split(',', $enc_list); + if ($p[1] == 'EUC-JP') { + $enc_list = 'ASCII,SJIS,EUC-JP,JIS'; + } else { + $enc_list = 'ASCII,EUC-JP,SJIS,JIS'; + } + + return TRUE; + } // end of the 'PMA_change_enc_order' function + + + /** + * Kanji string encoding convert + * 2002/1/4 by Y.Kawada + * + * @param string the string to convert + * @param string the destinasion encoding code + * @param string set 'kana' convert to JIS-X208-kana + * + * @global string the available encoding codes list + * + * @return string the converted string + */ + function PMA_kanji_str_conv($str, $enc, $kana) { + global $enc_list; + + if ($enc == '' && $kana == '') { + return $str; + } + + $nw = mb_detect_encoding($str, $enc_list); + if ($kana == 'kana') { + $dist = mb_convert_kana($str, 'KV', $nw); + $str = $dist; + } + if ($nw != $enc && $enc) { + $dist = mb_convert_encoding($str, $enc, $nw); + } else { + $dist = $str; + } + + return $dist; + } // end of the 'PMA_kanji_str_conv' function + + + /** + * Kanji file encoding convert + * 2002/1/4 by Y.Kawada + * + * @param string the name of the file to convert + * @param string the destinasion encoding code + * @param string set 'kana' convert to JIS-X208-kana + * + * @return string the name of the converted file + */ + function PMA_kanji_file_conv($file, $enc, $kana) { + if ($enc == '' && $kana == '') { + return $file; + } + + $tmpfname = tempnam('', $enc); + $fpd = fopen($tmpfname, 'wb'); + $fps = fopen($file, 'r'); + PMA_change_enc_order(); + while (!feof($fps)) { + $line = fgets($fps, 4096); + $dist = PMA_kanji_str_conv($line, $enc, $kana); + fputs($fpd, $dist); + } // end while + PMA_change_enc_order(); + fclose($fps); + fclose($fpd); + unlink($file); + + return $tmpfname; + } // end of the 'PMA_kanji_file_conv' function + + + /** + * Defines radio form fields to switch between encoding modes + * 2002/1/4 by Y.Kawada + * + * @param string spaces character to prepend the output with + * + * @return string xhtml code for the radio controls + */ + function PMA_set_enc_form($spaces) { + return "\n" + . $spaces . 'non' . "\n" + . $spaces . 'EUC' . "\n" + . $spaces . 'SJIS' . "\n" + . $spaces . ' ' . $GLOBALS['strEncto'] . '
' . "\n" + . $spaces . '' . "\n" + . $spaces . ' ' . $GLOBALS['strXkana'] . '
' . "\n"; + } // end of the 'PMA_set_enc_form' function + + + PMA_internal_enc_check(); + +} // $__PMA_ENCODING_LIB_INCLUDED +?> diff --git a/read_dump.php3 b/read_dump.php3 index c7b9ebced..77091241d 100644 --- a/read_dump.php3 +++ b/read_dump.php3 @@ -275,7 +275,17 @@ if ($sql_file != 'none') { else if (empty($id_bookmark) && get_magic_quotes_gpc() == 1) { $sql_query = stripslashes($sql_query); } -$sql_query = trim($sql_query); + +// Kanji convert SQL textfile 2002/1/4 by Y.Kawada +if (@function_exists('PMA_kanji_str_conv')) { + $sql_tmp = trim($sql_query); + PMA_change_enc_order(); + $sql_query = PMA_kanji_str_conv($sql_tmp, $knjenc, $xkana); + PMA_change_enc_order(); +} else { + $sql_query = trim($sql_query); +} + // $sql_query come from the query textarea, if it's a reposted query gets its // 'true' value if (!empty($prev_sql_query)) { diff --git a/sql.php3 b/sql.php3 index 21aedaf16..1d3f770ab 100755 --- a/sql.php3 +++ b/sql.php3 @@ -264,6 +264,11 @@ else { PMA_mysqlDie($error, $full_sql_query, '', $full_err_url); } + // tmpfile remove after convert encoding appended by Y.Kawada + if (function_exists('PMA_kanji_file_conv') && file_exists($textfile)) { + unlink($textfile); + } + // Gets the number of rows affected/returned if (!$is_affected) { $num_rows = @mysql_num_rows($result); diff --git a/tbl_dump.php3 b/tbl_dump.php3 index b1f4b38a1..3bb8ec3b5 100755 --- a/tbl_dump.php3 +++ b/tbl_dump.php3 @@ -14,6 +14,10 @@ function PMA_myHandler($sql_insert) { global $tmp_buffer; + // Kanji encoding convert feature appended by Y.Kawada (2001/2/21) + if (function_exists('PMA_kanji_str_conv')) { + $sql_insert = PMA_kanji_str_conv($sql_insert, $GLOBALS['knjenc'], $GLOBALS['xkana']); + } // Defines the end of line delimiter to use $eol_dlm = (isset($GLOBALS['extended_ins']) && ($GLOBALS['current_row'] < $GLOBALS['rows_cnt'])) ? ',' @@ -51,6 +55,10 @@ function PMA_myCsvHandler($sql_insert) global $add_character; global $tmp_buffer; + // Kanji encoding convert feature appended by Y.Kawada (2001/2/21) + if (function_exists('PMA_kanji_str_conv')) { + $sql_insert = PMA_kanji_str_conv($sql_insert, $GLOBALS['knjenc'], $GLOBALS['xkana']); + } // Result has to be displayed on screen if (empty($GLOBALS['asfile'])) { echo htmlspecialchars($sql_insert) . $add_character; @@ -218,17 +226,25 @@ else { : '\'' . $table . '\''; // If only datas, no need to displays table name if ($what != 'dataonly') { - $dump_buffer.= '# --------------------------------------------------------' . $crlf - . $crlf . '#' . $crlf - . '# ' . $strTableStructure . ' ' . $formatted_table_name . $crlf - . '#' . $crlf . $crlf - . PMA_getTableDef($db, $table, $crlf, $err_url) . ';' . $crlf; + $dump_buffer .= '# --------------------------------------------------------' . $crlf + . $crlf . '#' . $crlf + . '# ' . $strTableStructure . ' ' . $formatted_table_name . $crlf + . '#' . $crlf . $crlf + . PMA_getTableDef($db, $table, $crlf, $err_url) . ';' . $crlf; + } + if (function_exists('PMA_kanji_str_conv')) { // Y.Kawada + $dump_buffer = PMA_kanji_str_conv($dump_buffer, $knjenc, $xkana); } // At least data if (($what == 'data') || ($what == 'dataonly')) { - $dump_buffer .= $crlf . '#' . $crlf + $tcmt = $crlf . '#' . $crlf . '# ' . $strDumpingData . ' ' . $formatted_table_name . $crlf . '#' . $crlf .$crlf; + if (function_exists('PMA_kanji_str_conv')) { // Y.Kawada + $dump_buffer .= PMA_kanji_str_conv($tcmt, $knjenc, $xkana); + } else { + $dump_buffer .= $tcmt; + } $tmp_buffer = ''; if (!isset($limit_from) || !isset($limit_to)) { $limit_from = $limit_to = 0; @@ -239,6 +255,7 @@ else { $dump_buffer = ''; } PMA_getTableContent($db, $table, $limit_from, $limit_to, 'PMA_myHandler', $err_url); + $dump_buffer .= $tmp_buffer; } // end if $i++; diff --git a/tbl_properties.php3 b/tbl_properties.php3 index b9d9974ef..ed52b686b 100755 --- a/tbl_properties.php3 +++ b/tbl_properties.php3 @@ -732,6 +732,11 @@ if ($is_upload) { } // end if echo "\n"; +// Encoding setting form appended by Y.Kawada +if (function_exists('PMA_set_enc_form')) { + echo PMA_set_enc_form(' '); +} + // Bookmark Support if ($cfgBookmark['db'] && $cfgBookmark['table']) { if (($bookmark_list = PMA_listBookmarks($db, $cfgBookmark)) && count($bookmark_list) > 0) { @@ -898,6 +903,12 @@ if (PMA_PHP_INT_VERSION >= 40004) { } } echo "\n"; + +// Encoding setting form appended by Y.Kawada +if (function_exists('PMA_set_enc_form')) { + echo '
' . "\n" + . PMA_set_enc_form(' '); +} ?>