kadir_cakir
kadir_cakir

Reputation: 1073

PHP scandir filenames with Turkish characters

I am listing documents with PHP scandir. I have problem with some characters like ğ, ı, ş... So this is my code;

$directory = "document";
$scanned_directory = array_diff(scandir($directory, 1), array('..', '.'));
foreach ($scanned_directory as &$value) {
    echo utf8_encode($value);
}

Actually the filename is "şığx.jpg" but the output is "þýðx.jpg". utf8_encode did not solved this. Can you help me? Thank you.

Upvotes: 0

Views: 1604

Answers (1)

Marek
Marek

Reputation: 7433

utf8_encode will not help you here, as your filesystem is likely in different encoding. Use

echo iconv($in_charset, 'UTF-8', $value);

where $in_charset might be ISO-8859-9, windows-1254, or CP857.

Or if you haven't tried, maybe your filesystem is in utf already ;).

Upvotes: 1

Related Questions