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.
Advertisement
Answer
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 ;).