php - Save filename with unicode chars -
i have searched on internet , so, still no luck in following:
i know, how save file using file_put_contents
when filename has unicode characters. (windows 7 os)
$string = "jérôme.jpg" ; //utf-8 string file_put_contents("images/" . $string, "stuff");
resuts in file:
jГ©rГґme.jpg
tried possible combinations of such functions iconv
, mb_convert_encoding
possible encodings, converting source file different encodings well. proper headers set, browser recognises utf-8
properly.
however, can copy-paste , create file such name in explorer's gui, how make via php?
the last hardcore solution urlencode
string , save file.
this might late found solution close hurting issue me well. forget iconv , multibyte solutions; problem is on windows! (in link you'll find it's beauty this.)
after numerous attempts , ways solve this, met urlify , decided best way cope unicode-in-filenames transliterate them before writing file.
example of transliterating filename before saving it:
$filename = "Αρχείο.php"; // greek name 'file' echo urlify::filter($filename,128,"",true); // output: arxeio.php
Comments
Post a Comment