Re: How to get WIN-1255 encoded string

From: Date: Sun, 07 Nov 2004 19:50:19 +0000
Subject: Re: How to get WIN-1255 encoded string
References: 1 2  Groups: php.general php.i18n 
Request: Send a blank email to php-general+get-201446@lists.php.net to get a copy of this message
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

« previous php.general (#201446) next »