Home  >  Article  >  Backend Development  >  Source code mp4 download A tool that can find all Chinese characters in the source code

Source code mp4 download A tool that can find all Chinese characters in the source code

WBOY
WBOYOriginal
2016-07-29 08:34:571539browse

A tool that can find all Chinese characters in the source code
Just fill in the path you want to find $sf.
Function
1 Find all Chinese
2 Ignore Chinese in comment statements
3 Add files and folders that need to be ignored
4 Generate log files
If you are worried about updating the language pack for your software
Please use this tool.
My example:
http://127.0.0.1/tools/searchcn.php
http://127.0.0.1/tools/cnlog.txt

Copy the code The code is as follows:


set_time_limit(0);
ob_implicit_flush();
//Comment format
$remark = array(
, array('//debug', "rn")
, array('/**', '*/')
, array('/*debug&#&*/')
, array('/*note&#&*/')
, array('//note', "rn")
) ;
//The following directories and files are not queried
$filter = 'forumdata|config.inc.php|debug|test|readme|utilities|upgrade|.tpl.php|index.htm|.lang.php';
//Project directory
$sf = 'd:\data\labs\develop\dzhead\';
//Log directory
$logname = 'cnlog.txt';
$langfile = 'lang.php';
$log = fopen($logname, 'w');
fclose($log);
$lf = fopen($langfile, 'wb');
fwrite($lf, "rnrnt'spilt' => '--- --------------------------------------------------' ,");
fclose($lf);
$lf = fopen($langfile, 'ab');
$ptag = '\';
findfile($sf);
fwrite($lf, "rn); rnrn?>");
fclose($lf);
function findfile($sf){
global $ptag, $logname, $filter, $lf;
$log = fopen($logname, 'ab');
global $remark;
if(is_dir($sf)) {
if($dh = opendir($sf)) {
while(($file = readdir($dh)) !== false) {
if( $file == '.' || $file == '..') {
                                                                              Findfile($sf.$file. $ptag);
                 } elseif((preg_match('/.php$/', $file) || preg_match('/.htm$/', $file)) && !preg_match('/('.$filter. ')/', $sf.$file)) {
                                                                                                                                                                 fclose($sfp);
 explode($v[0], $buf, 2)) > 1) { $ Data. = $ Strcut [0];
IF (($ Strcut = Explode ($ v [1], $ Strcut [1], 2)) & gt; 1) {
$ buf = $ Strcut [1];
                                                                                      else {
                                $buf = $strcut[0];
                                break;
                            }
                        }
                        $data .= $strcut[0];
                        $buf = $data;
                    }
                    $data = $buf;
                    $lines = 0;
                    $cn = $str = '';
                    $cns = 0;
                    $ldata = "rnt'".str_replace('.', '_', $file)."' => '";
                    for($i = 0; $i < strlen($data); $i++){
                        $c = ord($data{$i});
                        if($c == 0x0A || $data{$i+1} == ''){
                            $lines++;
                            if(!empty($cn)){
                                $ldata .= "',";
                                $ldata = str_replace("rnt'".str_replace('.', '_', $file)."' => '',", '', $ldata);
                                fwrite($lf, $ldata);
                                $cn = "rn$lines:".$cn;
                                $str .= $cn;
                                $cn = '';
                                $ldata = "rnt'".str_replace('.', '_', $file)."' => '";
                            }
                        } elseif($c >= 0x81 && $c <= 0xFE) {
                            $c = ord($data{++$i});
                            if($c >= 0x40 && $c <= 0xFE) {
                                $cn .= $data{$i-1}.$data{$i};
                                $ldata .= $data{$i-1}.$data{$i};
                                while(($c = ord($data{++$i})) != 0x3C && $c != 0x0A && $c != 0x0D && $c != 0x27 && $c != 0x3E && $c != 0x3B && $c != 0x22 && $c != 0x3D && $c < 0x81) {
                                    $space .= chr($c);
                                }
                                $i--;
                                if(ord($data{$i+1}) < 0x81) {
                                    $cns++;
                                    $cn .= '$';
                                    $ldata .= "',rnt'".str_replace('.', '_', $file)."' => '";
                                } else {
                                    $cn .= $space;
                                }
                                $space = '';
                            }
                        }
                    }
                                                                                                                                                      --- (Total $cns places)");
                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                           
}
 fclose($log);
}
?>


The above introduces source code mp4 download, a tool that can find all Chinese characters in the source code, including source code mp4 download. I hope it will be helpful to friends who are interested in PHP tutorials.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn