return mb_convert_encoding($string, "UTF-8", mb_detect_encoding($string, .... Clean a string for use as filename by simply replacing all unwanted characters with underscore (ASCII converts to 7bit).
php.net