如题,编码太多都用不上,只要我们常用的。
在使用PHPMYAdmin的时候,常用的字符集一般有GBK,GB2312或UTF8 可以在修改或添加字符编码的时候,那字符集也太多了,如何才能只显示我们常用的字符集,让那些不常用的隐藏,或去掉那些不常用的字符集,让修改字段看起来更清爽,现提供一种解决方法。
首先说明一下我使用的PHPMyAdmin版本 3.5.2.2
找到: \libraries\mysql_charsets.lib.php
找到: function PMA_generateCharsetDropdownBox() 函数
在:foreach ($mysql_charsets as $current_charset) { 循环后加一句
if(!in_array($current_charset,array('gb2312','gbk','utf8'))){ continue; }
if(!in_array($current_collation,array('gb2312_bin','gb2312_chinese_ci','gbk_bin','gbk_chinese_ci','utf8_general_ci'))) { continue; }
function PMA_generateCharsetDropdownBox($type = PMA_CSDROPDOWN_COLLATION, $name = null, $id = null, $default = null, $label = true, $indent = 0, $submitOnChange = false, $displayUnavailable = false) { global $mysql_charsets, $mysql_charsets_descriptions, $mysql_charsets_available, $mysql_collations, $mysql_collations_available; if (empty($name)) { if ($type == PMA_CSDROPDOWN_COLLATION) { $name = 'collation'; } else { $name = 'character_set'; } } $return_str = '<select xml:lang="en" dir="ltr" name="' . htmlspecialchars($name) . '"' . (empty($id) ? '' : ' id="' . htmlspecialchars($id) . '"') . ($submitOnChange ? ' class="autosubmit"' : '') . '>' . "\n"; if ($label) { $return_str .= '<option value="">' . ($type == PMA_CSDROPDOWN_COLLATION ? __('Collation') : __('Charset')) . '</option>' . "\n"; } $return_str .= '<option value=""></option>' . "\n"; foreach ($mysql_charsets as $current_charset) { if(!in_array($current_charset,array('gb2312','gbk','utf8'))){ continue; } if (!$mysql_charsets_available[$current_charset]) { continue; } $current_cs_descr = empty($mysql_charsets_descriptions[$current_charset]) ? $current_charset : $mysql_charsets_descriptions[$current_charset]; if ($type == PMA_CSDROPDOWN_COLLATION) { $return_str .= '<optgroup label="' . $current_charset . '" title="' . $current_cs_descr . '">' . "\n"; foreach ($mysql_collations[$current_charset] as $current_collation) { if(!in_array($current_collation,array('gb2312_bin','gb2312_chinese_ci','gbk_bin','gbk_chinese_ci','utf8_general_ci'))) { continue; } if (!$mysql_collations_available[$current_collation]) { continue; } $return_str .= '<option value="' . $current_collation . '" title="' . PMA_getCollationDescr($current_collation) . '"' . ($default == $current_collation ? ' selected="selected"' : '') . '>' . $current_collation . '</option>' . "\n"; } $return_str .= '</optgroup>' . "\n"; } else { $return_str .= '<option value="' . $current_charset . '" title="' . $current_cs_descr . '"' . ($default == $current_charset ? ' selected="selected"' : '') . '>' . $current_charset . '</option>' . "\n"; } } $return_str .= '</select>' . "\n"; return $return_str; }
其它版本的PHPMyadmin可以参考该方法 ,此方法没有修改数据库的字符集,只是让不需要的字符集不显示仅此而已!!
___________________________________________________________________
PHPMYADMIN 去掉不需要的字符集 PHPMYADMIN 隐藏不需要的字符集,不想要的字符集