你可以下utf-8和gb2312的dedecms啊, 把模板文件换了就行,如果用批处理或php,速度也去不了那里

解决方案 »

  1.   

    遍历模板目录文件,用找出meta部分批量替换掉,很快
      

  2.   

    function explorerdir($sDir){

    static $aTempArr=array();
    $dp=opendir($sDir);
    while ($sFileName = readdir($dp)){

    if ($sFileName !='.' && $sFileName !='..'){  

    $sPath=$sDir."/" . $sFileName; 
        if ( is_dir($sPath)){

         explorerdir($sPath);   
        } else  {
        
    // $filetime=date("Y-m-d H:i:s",filectime("$path")); 
    // $fp=$path.",".$filetime;
    $fp=$sPath;
    $aTempArr[]=$fp;
        }
       }
    }
    closedir($dp);
    return $aTempArr;
    }
    $aFiles = explorerdir("路径");
    foreach($aFiles as $iKey => $sFiles) {

    $sContent = file_get_contents($sFiles);
    $sContent = str_ireplace('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />', '<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />', $sContent);
    file_put_contents($sFiles, $sContent);
    unset($sContent);
    }
      

  3.   

    谢谢iseagold,这只是该meta,直接改meta不用editplus转码的话中文还是会乱码的,因为它本质是utf文件。
    回coolesting ,如果是自己做的模板或者下载人家的模板,而且数量很多,这样做就有点慢了。能快就快
      

  4.   

    方法一,找出meta 换掉。
    方法二,遍历文件,将文件读取后,再转换格式,再生成。
      

  5.   

    我记得window下有编码转换器,可以批量换文件编码,以前用过, 记不起不什么, 英文的,是u开头, 你去google下。
      

  6.   

    那就把源文件删除,记住删除的文件名,再fwrite就改掉了
      

  7.   


    是这个吧:http://www.20ju.com/content/V52930.htm
    我用它将utf-8文件转为gbk文件,结果出来时乱码的
      

  8.   

    是先file_get_contents()读取源文件的代码,在fwrite到新文件那里吗?貌似这样做还是utf的吧
      

  9.   


    function explorerdir($sDir){

    static $aTempArr=array();
    $dp=opendir($sDir);
    while ($sFileName = readdir($dp)){

    if ($sFileName !='.' && $sFileName !='..'){  

    $sPath=$sDir."/" . $sFileName; 
        if ( is_dir($sPath)){

         explorerdir($sPath);   
        } else  {
        
    // $filetime=date("Y-m-d H:i:s",filectime("$path")); 
    // $fp=$path.",".$filetime;
    $fp=$sPath;
    $aTempArr[]=$fp;
        }
       }
    }
    closedir($dp);
    return $aTempArr;
    }
    $aFiles = explorerdir("D:/wamp/www/dedecms/templets/default");
    foreach($aFiles as $iKey => $sFiles) {

    $sContent = file_get_contents($sFiles);
    $sContent = str_ireplace('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />', '<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />', $sContent);
    $sContent = iconv("UTF-8", "gb2312", $sContent);
      unlink($sFiles);
    file_put_contents($sFiles, $sContent);
    unset($sContent);
    }
    我试了下这样是可以的
      

  10.   

    iseagold你果然是世界第一猛男,能行!!!
      

  11.   

    txt文件也可以这样使用转换吗   ?