From the filenames, recursively in the current directory, I need to remove all "foreign" characters (Chinese, Amharik, Sanskrit, EU accented/diacritical, more exotic ones..., etc.) other than the following "allowed" characters:
a-zA-Z0-9.-_=~
The script below gets stuck with and displays warnings with ???
in place of the foreign characters.
<?php
$dir = "getcwd()";
$files = scandir($dir);
function clean($string) {
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string);
}
?>
Any hints please? PHP. Windows Command Line.
Desired input/output example:
abcወውልውABñC.ext
abcABC.ext