On Sun, 2004-11-07 at 20:42 +0100, Fredrik Tolf wrote:
> On Sun, 2004-11-07 at 13:57 +0200, Marina Markus wrote:
> > Is there a possibility in PHP allowing to encode a string
> > with WIN-1255 character set encoding? The result should look like:
> >
> > =?windows-1255?B?Rlc6IOz26eHl+CDk8uXj6e0=?=
> >
> > which the mail client then is able to decode back into Hebrew.
>
> If you're running PHP5, you might want to look at iconv_mime_encode. If
> not, you can take these functions, which are from a GPL:d webmail I'm
> writing, and adapt them to your purpose:
> [snip]
> return("=?UTF-8?B?" . encodemime($header, "base64") . "?=");
> [snip]
Sorry, it seems the `encodemime' function was mine as well:
function encodemime($text, $encoding)
{
if($encoding == "quoted-printable")
{
$nt = "";
for($i = 0; $i < strlen($text); $i++)
{
$c = substr($text, $i, 1);
if(($c == "=") || (ord($c) >= 128))
$nt .= "=" . dechex(ord($c));
else
$nt .= $c;
}
return($nt);
}
if($encoding == "base64")
return(base64_encode($text));
return($text);
}
Sorry for taking two mails.
Fredrik Tolf
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php