encoding - UTF-8, PHP, Win7 - Is there a solution now to save UTF-8-filenames on Win 7 using php? -
following link chains on stackoverflow found part of answer:
https://stackoverflow.com/a/10138133/3716796 umberto salsi
(and on same question: https://stackoverflow.com/a/2950046/3716796 artefacto)
in short: 'php communicate[s] underlying file system "non-unicode aware program"', , because of filenames given php windows , vice versa automatically translated/reencoded windows. causes errors. , seemingly can't stop automatic reencoding.
(and https://stackoverflow.com/a/2888039/3716796 artefacto:
"php not use wide win32 api calls, you're limited codepage.")
, @ https://bugs.php.net/bug.php?id=47096 there bug report php.
though on there nicolas suggests, com-object might work!
$fs = new com('scripting.filesystemobject', null, cp_utf8);
maybe try sometimes.
so there part of questionleft : there php6 out, or withdrawn, or there new on php topic?
// full question
questions topic 1 5 years old. php save file using file_put_contents($dir . '/' . $_post['filename'], $_post['content']);
when $_post['filename'] utf-8 encoded, example "Крым.xml" ? saved Крым.xml
i checked filename variable, can sure it's utf-8: echo mb_detect_encoding($_post['filename']);
- is there new in php accomplish it?
- at places read php 6 able it, php 6 if i remember right, has been withdrawn. ?
- in windows explorer can change name of file "Крым.xml". far have understood old questions&answers, should possible use file_put_contents if filename-var encoded encoding used windows 7 , it's ntfs disc. there 3 old question answers claim have succeeded:
php file handling utf-8 special characters
convert utf-16le utf-8 in php
, php: how create unicode filenames
overall , approved answers not possible. checked suggested answers myself, , none works. - how definitly , absolute accuracy find out, in encoding win 7 , explorer saves filename on ntfs disc , german language setting? said: can create file "Крым.xml" in explorer.
my conclusion:
1. either file_put_contents doesn't work correctly when handing on filename (which tried conversions utf-16, utf-16le, iso-8859-1 , windows-1252) windows,
2. or file_put_contents doesn't implement way call windows' own file function in appropriate way (so second possibility mean it's not bug not implemented.) (for example notepad++ has no problems creating, writing , renaming file called Крым.xml.)
just 1 example of error messages got, in case when used mb_convert_encoding($thefilename , 'windows-1252' , 'utf-8')
"warning: file_put_contents(dirtosavein/????.xml): failed open stream: no error in c:\aa xampp\htdocs\myinterface.lo\myinterface\phpwritelocalsearchresponsexml.php on line 26 " other conversion got other error messages, ranging 'invalid characters' no string recognized @ all.
greetings john
php starting 7.1.0alpha2 supports utf-8 filenames on windows.
thanks.
Comments
Post a Comment