note 117312 added to function.iconv
| From: | BasVijfwinkel | Date: | Wed, 20 May 2015 07:13:18 +0000 |
| Subject: | note 117312 added to function.iconv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202616@lists.php.net to get a copy of this message | ||
You can use iconv in order to access filenames or paths that containt Japanese (and probably also
Koreans and Chinese) characters that would normally not be processed correctly by 'copy',
'fopen', 'rename', etc...
<?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);
?>
Note that there are some characters which do not have a SJIS equivalent like 'â¡'.
They will be omitted by iconv without any error or warning.
----
Server IP: 72.52.91.14
Probable Submitter: 124.39.122.119
----
Manual Page -- http://php.net/manual/en/function.iconv.php
Edit -- https://master.php.net/note/edit/117312
Del: integrated -- https://master.php.net/note/delete/117312/integrated
Del: useless -- https://master.php.net/note/delete/117312/useless
Del: bad code -- https://master.php.net/note/delete/117312/bad+code
Del: spam -- https://master.php.net/note/delete/117312/spam
Del: non-english -- https://master.php.net/note/delete/117312/non-english
Del: in docs -- https://master.php.net/note/delete/117312/in+docs
Del: other reasons-- https://master.php.net/note/delete/117312
Reject -- https://master.php.net/note/reject/117312
Search -- https://master.php.net/manage/user-notes.php