Skip to content

Instantly share code, notes, and snippets.

@bato3
Created July 31, 2014 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bato3/bff87a3c7c173168fa03 to your computer and use it in GitHub Desktop.
Save bato3/bff87a3c7c173168fa03 to your computer and use it in GitHub Desktop.
UTF-8Y fixer
<pre><?php
set_time_limit(3600);
ini_set('max_execution_time',3600);
$dirs = Array();
$files = array();
function fixUTF8($dir)
{
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if($file != "." && $file != "..") {
if(is_dir($dir.'\\'.$file)){
fixUTF8($dir.'\\'.$file);
}else{
$x = file_get_contents($dir.'/'.$file);
print 'fix:' .$dir.'/'.$file . ': ';
if(substr($x,0,3) == ''){
file_put_contents($dir.'/'.$file, substr($x,3));
print "DONE\n";
}
else
print "NOT NEED\n";
}
}
}
closedir($handle);
//die();
}
}
fixUTF8('.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment