note 117311 added to function.copy

From: Date: Wed, 20 May 2015 07:09:32 +0000
Subject: note 117311 added to function.copy
Groups: php.notes 
Request: Send a blank email to php-notes+get-202615@lists.php.net to get a copy of this message
Paths and filenames with Japanese characters are not handled correctly if you are running Apache/PHP on a Windows machine. With the following code you can convert e.g. the network path to the appropriate encoding so that Windows understands where to look: <?PHP function convertPath($path) { //split networkpath into parts $parts = explode('\\',$path); // convert each part to SJIS foreach($parts as $index => $part) { $parts[$index] = iconv('UTF-8','SJIS//IGNORE',$part); } // put the network path back together return implode('\\',$parts); } $oldname = convertPath('c:/Temp/ほげほげ.pdf'); $newname = convertPath('\\\\PFSV0100\\DATA\\06:個人別\\333328_ほげほげ\\test_あいうえお.pdf'); copy($oldname, $newname); ?> There are however a number of characters that cannot be converted correctly like '②' and '﨑' because there are no SJIS equivalents. ---- Server IP: 72.52.91.14 Probable Submitter: 124.39.122.119 ---- Manual Page -- http://php.net/manual/en/function.copy.php Edit -- https://master.php.net/note/edit/117311 Del: integrated -- https://master.php.net/note/delete/117311/integrated Del: useless -- https://master.php.net/note/delete/117311/useless Del: bad code -- https://master.php.net/note/delete/117311/bad+code Del: spam -- https://master.php.net/note/delete/117311/spam Del: non-english -- https://master.php.net/note/delete/117311/non-english Del: in docs -- https://master.php.net/note/delete/117311/in+docs Del: other reasons-- https://master.php.net/note/delete/117311 Reject -- https://master.php.net/note/reject/117311 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#202615) next »