Anonymous
public text v1 · immutablefunction encode_mime($data)
{
$array = utf8_str_split($data);
$start = "=?UTF-8?B?";
$end = "?=";
$new = '';
while(sizeof($array))
{
$text = '';
while (sizeof($array) && strlen(base64_encode($text . $array[0])) < 63)
{
$text .= array_shift($array);
}
$new .= $start . base64_encode($text) . $end . ' ';
}
return substr($new, 0, -1);
}