Batch file renaming ANSI >> UNICODE?

It so happened that when became CPanel images, whose names are in Unicode(not Russian) became krajobrazu (like Chinese, but ANSI ) , so as to perform the reverse operation )

using php, windows app. or else,

cartons lot
October 8th 19 at 01:30
1 answer
October 8th 19 at 01:32
In PHP
define('IN_CONV','CP1251');
define('OUT_CONV','UTF-8');
$dir='/some/dir/'

ansiutf($dir);

function ansiutf($dir)
{
 if ($dh = opendir($dir)) {
 while (($file = readdir($dh)) !== false) {
 if($file!=='.' && $file!=='..' && is_dir($file)===false && is_image($file)===true)
rename($dir.$file,$dir.iconv(IN_CONV,OUT_CONV,$file));
elseif(is_dir($file)===true)
ansiutf($dir.$file.'/');
}
closedir($dh);
}
}

is_image($file)
{
$ext=substr($file,strrpos($file,'.'));
 if($ext==='.gif' || $ext==='.png' || $ext==='.jpg' || $ext==='.jpeg')
 return true;
else
 return false;
}
Thanks, I'll try ) - rosina_Zieme commented on October 8th 19 at 01:35

Find more questions by tags Hosting