[dokuwiki] Re: UTF-8 question

  • From: Riny Heijdendael <riny@xxxxxxxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Thu, 29 Sep 2005 10:32:34 +0200

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:

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



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);

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);

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

        return $input;

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

Other related posts: