Das heisst du glaubst mir das ich ein problem habe und jetzt suchen wir noch eine Lösung

/// return list of directory entries
function dir_scan_unicode(
$path = NULL /// path to directory
) {
if (!is_dir($path)) {
return FALSE;
}
// entfernen|umbauen, worueber DIR stolpern koennte:
$path = preg_replace(
'/(?:\Afile:\/\/(localhost)?\/|\/)/Se',
'strlen("$0") > 1 ? "" : "\x5c"',
$path
);
// fuer CMD:
// /U Umstellen der Ausgabe auf UTF-16LE
// /C nach Aufruf des folgenden Kommandos sofort zurueckkehren
// fuer DIR:
// /B nur "long file names" anzeigen
// /C nach Aufruf des folgenden Kommandos sofort zurueckkehren
// fuer DIR:
// /B nur "long file names" anzeigen
exec('cmd /U /C dir ' . cmd_escape($path). ' /B', $lines, $return_val);
if (0 !== $return_val) { // 0 means success
return FALSE;
}
foreach ($lines as $line_key => $line) {
//* konvertiert UTF-16LE nach UTF-8
//
$lines[$line_key] = mb_convert_encoding(
(strlen($line) & 1) ? substr($line, 1, -2) : substr($line, 0, -2),
'UTF-8', // from encoding
'UTF-16LE' // to encoding
);
//*/
/* konvertiert UTF-16LE nach HTML-ASCII + NCR (&#dec-zahl;)
// Fuer die testweise Ausgabe (u.A. im Browser)
$codepoints = unpack(
'v*',
(strlen($line) & 1) ? substr($line, 1, -2) : substr($line, 0, -2)
);
foreach ($codepoints as $cp_key => $codepoint) {
$codepoints[$cp_key] = $codepoint > 127
? sprintf('&#%d;', $codepoint)
: chr($codepoint);
}
$lines[$line_key] = implode($codepoints);
//*/
// Leerzeilen entfernen (eigentlich nur die letzte)
if (!isset($lines[$line_key][0])) {
unset($lines[$line_key]);
}
}
return $lines;
}
// um Code-Injections zu verhindern
// escapeshellcmd() funktioniert nicht wie erwartet
function cmd_escape(
$path = NULL
) {
// implementation left to you as an exercise ;-)
return $path;
}
// getestete Pfade:
$path = 'f:\\test\\php-resource\\cyrillic-filename';
$path = 'f:\test\php-resource\cyrillic-filename';
$path = 'f:/test/php-resource/cyrillic-filename';
$path = 'file:///f:/test/php-resource/cyrillic-filename';
$path = 'file://localhost/f:/test/php-resource/cyrillic-filename';
foreach ($entries as $entry) {
echo '<br />', $entry, '';
}
Kommentar