I am doing this:
$files = scandir('./data');
foreach($files as $file) {
echo $file;
}
I have also tried this:
foreach (new DirectoryIterator('./music') as $fileInfo) {
echo $fileInfo->getFilename();
}
It works fine for most file names, except for those with special characters, such as é or ø. The output will contain black diamonds with question marks (�). I have tried a lot of different methods for converting from and to UTF-8, UTF-16, ISO-8859-1, etc. Eventually I realised that php must be outputting a �, instead of the browser displaying it because it doesn't know what the character is.
How do I properly get the name of a file with special characters?
It would be okay if e.g. éø is converted to eo, as long as I do not lose characters (géu -> gu)