note 40598 added to ref.iconv
| From: | MagicalTuxatFF dot ST at rn2 dot php dot net | Date: | Tue, 09 Mar 2004 10:15:57 +0000 |
| Subject: | note 40598 added to ref.iconv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-66478@lists.php.net to get a copy of this message | ||
If you forgot to compile iconv in PHP but you want to use the function iconv() and you have the
iconv binary accessible to the web server, you can use this little function :
<?
if (!function_exists('iconv')) {
function iconv($src,$dst,$str) {
$str=str_replace('END','E-ND',$str); // make sure we're not
stopped
$str.="\nEND";
$prog=popen('/usr/bin/iconv -f '.escapeshellarg($src).' -t
'.escapeshellarg($dst)." << END\n".$str,'r');
$res='';
while(!feof($prog)) $res.=fread($prog,4096);
pclose($prog);
$res=str_replace('E-ND','END',$res);
$res=substr($res,0,strlen($res)-1); // remove the \n we added
return $res;
}
}
?>
If your hosting company allows you to use popen and gave you shell access, you can even compile a
static build of the iconv binary and upload it to your FTP, then update the popen parameter in order
to reflect to your configuration. Remember that popen requires /bin/sh to exist !
----
Manual Page -- http://www.php.net/manual/en/ref.iconv.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40598
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40598&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40598&report=yes
Search -- http://master.php.net/manage/user-notes.php