带有土耳其语字符的PHP scandir文件名 [英] PHP scandir filenames with Turkish characters
本文介绍了带有土耳其语字符的PHP scandir文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用PHP scandir列出文档.我对某些字符(例如ğ,ı,ş...)有疑问 这是我的代码;
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);
}
实际上文件名是şığx.jpg",但输出是þýðx.jpg". utf8_encode没有解决此问题.你能帮助我吗?谢谢.
Actually the filename is "şığx.jpg" but the output is "þýðx.jpg". utf8_encode did not solved this. Can you help me? Thank you.
推荐答案
utf8_encode
在这里无济于事,因为您的文件系统可能采用不同的编码.使用
utf8_encode
will not help you here, as your filesystem is likely in different encoding. Use
echo iconv($in_charset, 'UTF-8', $value);
其中$in_charset
可能是ISO-8859-9
,windows-1254
或CP857
.
或者,如果您没有尝试过,也许您的文件系统已经在utf中;).
Or if you haven't tried, maybe your filesystem is in utf already ;).
这篇关于带有土耳其语字符的PHP scandir文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文