2 /********************************************************************************
3 * include/encoding.inc.php : decoding subroutines
4 * --------------------------
6 * This file is part of the banana distribution
7 * Copyright: See COPYING files that comes with this distribution
8 ********************************************************************************/
10 /** Decodes quoted-printable and UTF8 headers
11 * @param STRING $_value string to decode
14 function _headerdecode($charset, $c, $str) {
15 $s = ($c == 'Q') ?
quoted_printable_decode($str) : base64_decode($str);
16 $s = iconv($charset, 'iso-8859-15', $s);
17 return str_replace('_', ' ', $s);
20 function headerDecode($value) {
21 $val = preg_replace('/(=\?[^?]*\?[BQ]\?[^?]*\?=) (=\?[^?]*\?[BQ]\?[^?]*\?=)/', '\1\2', $value);
22 return preg_replace('/=\?([^?]*)\?([BQ])\?([^?]*)\?=/e', '_headerdecode("\1", "\2", "\3")', $val);