PmWiki的中文乱码改造
Rocket(居然是校友,隔壁化学系的)发来封信,讲了“让PmWiki侧底支持中文gb2312”,受益不少。
以下内容转自Chinix.net
对PmWiki.php程序修改如下(基于0.5.5,其他版本应能类推):1)将Line 185~187
$Newline = "\262";
$KeepToken = "\263";
$LinkToken = "\264";
改为
$Newline = "\x81"; //$Newline = "\262"; //Modi by Rocket. 2003.6.25
$KeepToken = "\x82"; //$KeepToken = "\263"; //Modi by Rocket. 2003.6.25
$LinkToken = "\x83"; //$LinkToken = "\264"; //Modi by Rocket. 2003.6.252)程序中涉及阅读的子程序有两个:
Line 764
function HandleBrowse($pagename)
作用是阅读文件。Line 802
function HandleEdit($pagename)
作用是读入文件供编辑本页。
做子函数Patch_GB2312()和Patch_BackOld()
function Patch_GB2312($pagefilename){
//add by Rocket. 2003.6.25
global $Newline,$KeepToken,$LinkToken;
if (file_exists('wikilib.d/'.$pagefilename)&!file_exists('wiki.d/'.$pagefilename)){
$Newline = "\262";
$KeepToken = "\263";
$LinkToken = "\264";
}
}function Patch_BackOld(){
//add by Rocket. 2003.6.25
global $Newline,$KeepToken,$LinkToken;
$Newline = "\262";
$KeepToken = "\263";
$LinkToken = "\264";
}
加入队尾Line 997.修改HandleBrowse()的 Line769 和HandleEdit()的 Line 806
if (!$page) { Abort("Invalid page name"); }
改为
if (!$page) { Abort("Invalid page name"); } else Patch_GB2312($pagename); //Modi by Rocket. 2003.6.253)由于HandleEdit后还要输出PmWiki.EditQuickReference,快速编辑参考,这是一个老文档,需要不管三七二十一,变回老的分隔符,所以修改Line 812,强制变量赋值:
$HTMLTitle = "Edit $pagename"; $GCount = 0;
改为:
$HTMLTitle = "Edit $pagename"; $GCount = 0;Patch_BackOld();//Modi by Rocket. 2003.6.254)剩下一些小打小闹的修改,有的您可能前面已经做了:
将Line57
"Content-Type: text/html; charset=iso-8859-1;");
改为:
"Content-Type: text/html; charset=gb2312;"); //"Content-Type: text/html; charset=iso-8859-1;");Modi by Rocket. 2003.6.25