[dokuwiki] Re: UTF-8 question

Andreas Gohr wrote:

Riny Heijdendael writes:

Others gave you some info already. There is no decoding support for this in DokuWiki (only encoding in inc/mail.php) However have a look here for two PHP lines to decode them:
http://wiki.splitbrain.org/phpsnippets#decode_mail-subjects

Thanks Andi, but de _decodeHeader function from the pear mime library does the trick very neat, but thanks a lot!


Riny

====================

function _decodeHeader($input)
{
// Remove white space between encoded-words
$input = preg_replace('/(=\?[^?]+\?(q|b)\?[^?]*\?=)(\s)+=\?/i', '\1=?', $input);


// For each encoded-word...
while (preg_match('/(=\?([^?]+)\?(q|b)\?([^?]*)\?=)/i', $input, $matches)) {


            $encoded  = $matches[1];
            $charset  = $matches[2];
            $encoding = $matches[3];
            $text     = $matches[4];

            switch (strtolower($encoding)) {
                case 'b':
                    $text = base64_decode($text);
                    break;

case 'q':
$text = str_replace('_', ' ', $text);
preg_match_all('/=([a-f0-9]{2})/i', $text, $matches);
foreach($matches[1] as $value)
$text = str_replace('='.$value, chr(hexdec($value)), $text);
break;
}


            $input = str_replace($encoded, $text, $input);
        }

        return $input;
    }


-- DokuWiki mailing list - more info at http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: