function EncodeMimeString($text, $charset) { if (!CEvent::Is8Bit($text)) { return $text; } //$maxl = IntVal((76 - strlen($charset) + 7)*0.4); $res = ""; $maxl = 40; $eol = CEvent::GetMailEOL(); $len = strlen($text); for ($i = 0; $i < $len; $i = $i + $maxl) { if ($i > 0) { $res .= $eol . "\t"; } $res .= "=?" . $charset . "?B?" . base64_encode(substr($text, $i, $maxl)) . "?="; } return $res; }