/** * @param string $str * @return string */ function DecodeHeaderString($str, $fromCharset, $toCharset, $withSpecialParameters = false) { $bool = false; $newStr = $withSpecialParameters ? ConvertUtils::WordExtensionsDecode($str) : $str; $bool = $newStr != $str; $str = str_replace("\r", '', str_replace("\t", '', str_replace("\n", '', $newStr))); /* $str = str_replace('?= =?', '?==?', $str); */ $str = preg_replace('/\\s+/', ' ', $str); $encodeArray = ConvertUtils::SearchEncodedPlaces($str); $c = count($encodeArray); for ($i = 0; $i < $c; $i++) { $tempArr = ConvertUtils::DecodeString($encodeArray[$i], $fromCharset, $toCharset); $str = str_replace($encodeArray[$i], ConvertUtils::ConvertEncoding($tempArr[1], $tempArr[0], $toCharset), $str); $bool = true; } $str = preg_replace('/[;]([a-zA-Z])/', '; $1', $str); return $bool ? $str : ConvertUtils::ConvertEncoding($str, $fromCharset, $toCharset); }