note 89029 modified in function.mb-convert-encoding by danbrown
| From: | danbrown@php.net | Date: | Wed, 18 Feb 2009 20:16:41 +0000 |
| Subject: | note 89029 modified in function.mb-convert-encoding by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150817@lists.php.net to get a copy of this message | ||
I used this function insted mb_convert_encoding, because mbstring wasn't enabled at my
comercial server. It only suports utf7, 8 e iso 8859-1:
<?php
function my_convert_encoding($string,$to,$from)
{
// Convert string to ISO_8859-1
if ($from == "UTF-8")
$iso_string = utf8_decode($string);
else
if ($from == "UTF7-IMAP")
$iso_string = imap_utf7_decode($string);
else
$iso_string = $string;
// Convert ISO_8859-1 string to result coding
if ($to == "UTF-8")
return(utf8_encode($iso_string));
else
if ($to == "UTF7-IMAP")
return(imap_utf7_encode($iso_string));
else
return($iso_string);
}
?>
--was--
I used this function insted mb_convert_encoding, because mbstring wasn't enabled at my
comercial server. It only suports utf7, 8 e iso 8859-1:
function my_convert_encoding($string,$to,$from)
{
// Convert string to ISO_8859-1
if ($from == "UTF-8")
$iso_string = utf8_decode($string);
else
if ($from == "UTF7-IMAP")
$iso_string = imap_utf7_decode($string);
else
$iso_string = $string;
// Convert ISO_8859-1 string to result coding
if ($to == "UTF-8")
return(utf8_encode($iso_string));
else
if ($to == "UTF7-IMAP")
return(imap_utf7_encode($iso_string));
else
return($iso_string);
}
http://php.net/manual/en/function.mb-convert-encoding.php