/** * @param string $sAttrName * @param string $sValue * * @return string */ public static function EncodeHeaderUtf8AttributeValue($sAttrName, $sValue) { $sAttrName = \trim($sAttrName); $sValue = \trim($sValue); if (0 < \strlen($sValue) && !\MailSo\Base\Utils::IsAscii($sValue)) { if (!empty($_SERVER['HTTP_USER_AGENT']) && 0 < \strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { $sValue = $sAttrName . '="' . \preg_replace('/[+\\s]+/', '%20', \urlencode($sValue)) . '"'; } else { $sValue = \MailSo\Base\Utils::AttributeRfc2231Encode($sAttrName, $sValue); } } else { $sValue = $sAttrName . '="' . \str_replace('"', '\\"', $sValue) . '"'; } return \trim($sValue); }