什么是GBK、UTF-8、BIG5编码?
发布网友
发布时间:2022-03-22 15:24
我来回答
共1个回答
热心网友
时间:2022-03-22 16:53
DZ6.1 后台导入不同编码的论坛插件和转换程序 (utf8/big5/gbk) #############################################
插件名称:DZ6.1 后台导入不同编码的论坛插件 (utf8/big5/gbk)
适用版本:Discuz!最新DZ 6.1(各版本,包括简繁GBK和UTF-8)
6.1版作者:Albey
4.1以前作者:Eiffel
最后更新:2008年5月31日18时10分
数据结构:未修改数据库
演示地址(UTF-8):http://www.magicsea.net/bbs
说明:1。提供的插件导入.rar是简体UTF-8的,其他的版本只要自己手动加代码就行了,sctc.inc.php不同版本有提供,因为utf-8的插件其实不多,所以才想到提供),这个是插件的导入文件的转换
2。GB to UTF-8的转换程序文件,是1.3版本,版权归作者所有,这个是插件的页面文件的转换。
版本状况:
2008.5 第1版,已测试
#############################################
安装方法(UTF-8)
1。查找templates\default下,admincp.lang.php 'plugins_import_ignore_version' => '允许导入不同版本 Discuz! 的插件(易产生错误!!)',复制代码在下面加: 'plugins_import_from_tc' => '导入繁体 UTF8 编码',
'plugins_import_from_sc' => '导入简体 UTF8 编码',
'plugins_import_from_big5' => '导入繁体 BIG5 编码',
'plugins_import_from_gbk' => '导入简体 GBK 编码',复制代码-----------------------------------------------
2。把sctc.inc.php,放到include下面,下载(include.rar ),然后找对应你自己BBS的版本
-----------------------------------------------
3。查找admin下,plugins.inc.php
查找: if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}复制代码在下面加: require_once DISCUZ_ROOT.'include/sctc.inc.php';复制代码-----------------------------------------------
查找: showtablerow('', '', '<input type="file" name="importfile" size="40" class="uploadbtn marginbot" />');
showtablerow('', '', '<input type="checkbox" name="ignoreversion" value="1" class="checkbox" /> '.lang('plugins_import_ignore_version'));复制代码下面加: showtablerow('', '', '<input class="radio" type="radio" name="code" value="utf_tc"> '.lang('plugins_import_from_tc'));
showtablerow('', '', '<input class="radio" type="radio" name="code" value="utf_sc"> '.lang('plugins_import_from_sc'));
showtablerow('', '', '<input class="radio" type="radio" name="code" value="big5"> '.lang('plugins_import_from_big5'));
showtablerow('', '', '<input class="radio" type="radio" name="code" value="gbk" checked> '.lang('plugins_import_from_gbk'));复制代码-----------------------------------------------
查找: $db->query("INSERT INTO {$tablepre}plugins ($sql1) VALUES ($sql2)");复制代码上面加: //utf8-gbk
switch($code) {
case "utf_tc":
$sql2=tc2sc($sql2);
break;
case "big5":
require_once DISCUZ_ROOT.'include/chinese.class.php';
$chs = new Chinese('BIG5', 'UTF8');
$sql2=$chs->Convert($sql2);
$sql2=tc2sc($sql2);
break;
case "gbk":
require_once DISCUZ_ROOT.'include/chinese.class.php';
$chs = new Chinese('GBK', 'UTF8');
$sql2=$chs->Convert($sql2);
break;
case "utf_sc":
break;
}
//utf8-gbk复制代码-----------------------------------------------
查找: $db->query("INSERT INTO {$tablepre}plugin$pluginconfig ($sql1) VALUES ($sql2)");复制代码上面加: //UTF8-GBK
switch($code) {
case "utf_tc":
$sql2=tc2sc($sql2);
break;
case "big5":
require_once DISCUZ_ROOT.'include/chinese.class.php';
$chs = new Chinese('BIG5', 'UTF8');
$sql2=$chs->Convert($sql2);
$sql2=tc2sc($sql2);
break;
case "gbk":
require_once DISCUZ_ROOT.'include/chinese.class.php';
$chs = new Chinese('GBK', 'UTF8');
$sql2=$chs->Convert($sql2);
break;
case "utf_sc":
break;
}
//UTF8-GBK复制代码-----------------------------------------------
页面文件最后>?前,加 //utf-8-gbk
function tc2sc($str){
$outstr="";
for($i=0; $i < strlen($str); $i++) {
$ch=ord(substr($str,$i,1));
if($ch > 127) {
$char=substr($str,$i,3);
$loc=strpos(strTC,$char);
if ($loc !== false) $char=substr(strSC,$loc,3);
$outstr.=$char;
$i+=2;
} else {
$outstr.=substr($str,$i,1);
}
}
return $outstr;
}
//utf-8-gbk复制代码-----------------------------------------------
4。查找admin下,styles.inc.php
查找: if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}复制代码在下面加: require_once DISCUZ_ROOT.'include/sctc.inc.php';复制代码-----------------------------------------------
查找: showtablerow('', '', '<input type="file" name="importfile" size="40" class="uploadbtn marginbot" />');
showtablerow('', '', '<input class="checkbox" type="checkbox" name="ignoreversion" id="ignoreversion" value="1" /><label for="ignoreversion"> '.lang('styles_import_ignore_version').'</label>');复制代码在下面加: showtablerow('', '', '<input class="radio" type="radio" name="code" value="utf_tc"> '.lang('plugins_import_from_tc'));
showtablerow('', '', '<input class="radio" type="radio" name="code" value="utf_sc"> '.lang('plugins_import_from_sc'));
showtablerow('', '', '<input class="radio" type="radio" name="code" value="big5"> '.lang('plugins_import_from_big5'));
showtablerow('', '', '<input class="radio" type="radio" name="code" value="gbk" checked> '.lang('plugins_import_from_gbk'));复制代码-----------------------------------------------
查找: $db->query("INSERT INTO {$tablepre}templates (name, directory, copyright)复制代码上面加: //utf8-gbk
switch($code) {
case "utf_tc":
$stylearray[tplname]=tc2sc($stylearray[tplname]);
$stylearray[copyright]=tc2sc($stylearray[copyright]);
$stylearray[name]=tc2sc($stylearray[name]);
break;
case "big5":
require_once DISCUZ_ROOT.'include/chinese.class.php';
$chs = new Chinese('BIG5', 'UTF8');
$stylearray[tplname]=$chs->Convert($stylearray[tplname]);
$stylearray[copyright]=$chs->Convert($stylearray[copyright]);
$stylearray[name]=$chs->Convert($stylearray[name]);
$stylearray[tplname]=tc2sc($stylearray[tplname]);
$stylearray[copyright]=tc2sc($stylearray[copyright]);
$stylearray[name]=tc2sc($stylearray[name]);
break;
case "gbk":
require_once DISCUZ_ROOT.'include/chinese.class.php';
$chs = new Chinese('GBK', 'UTF8');
$stylearray[tplname]=$chs->Convert($stylearray[tplname]);
$stylearray[copyright]=$chs->Convert($stylearray[copyright]);
$stylearray[name]=$chs->Convert($stylearray[name]);
break;
case "utf_sc":
break;
}
//utf8-gbk复制代码-----------------------------------------------
此页面最后?>前,加 //utf8-gbk
function tc2sc($str){
$outstr="";
for($i=0; $i < strlen($str); $i++) {
$ch=ord(substr($str,$i,1));
if($ch > 127) {
$char=substr($str,$i,3);
$loc=strpos(strTC,$char);
if ($loc !== false) $char=substr(strSC,$loc,3);
$outstr.=$char;
$i+=2;
} else {
$outstr.=substr($str,$i,1);
}
}
return $outstr;
}
//utf8-gbk复制代码utf-8版本完成
[ 本帖最后由 Albey 于 2008-6-18 02:23 编辑 ]截图.jpg (30.64 KB) 下载次数:832008-5-31 18:57插件导入.rar (90.42 KB) 下载次数:12502008-5-31 18:57简体UTF-8GB2UTF8.rar (23.15 KB) 下载次数:2212008-5-31 18:57转换文件的软件include.rar (19.63 KB) 下载次数:2102008-5-31 18:57sctc.inc.php