for me the code below works well on Win7 / ntfs, Apache 2.2.21.0 and PHP 5.3.8.0:
<?php // this source file is utf-8 encoded $fileContent = "Content of my file which contains Turkish characters such as şığŞİĞ"; $dirName = 'Dirname with utf-8 chars such as şığŞİĞ'; $fileName = 'Filename with utf-8 chars such as şığŞİĞ'; // converting encodings of names from utf-8 to iso-8859-9 (Turkish) $encodedDirName = iconv("UTF-8", "ISO-8859-9//TRANSLIT", $dirName); $encodedFileName = iconv("UTF-8", "ISO-8859-9//TRANSLIT", $fileName); mkdir($encodedDirName); file_put_contents("$encodedDirName/$encodedFileName.txt", $fileContent);
you can do the same for opening files:
<?php $fileName = "Filename with utf-8 chars such as şığ"; $fileContent = file_get_contents(iconv("UTF-8", "ISO-8859-9//TRANSLIT", "$fileName.txt")); print $fileContent;
hersly
source share