[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:
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
- References:
- [dokuwiki] UTF-8 question
- From: Riny Heijdendael
- [dokuwiki] Re: UTF-8 question
- From: Andreas Gohr
Other related posts:
- » [dokuwiki] UTF-8 question
- » [dokuwiki] Re: UTF-8 question
- » [dokuwiki] Re: UTF-8 question
- » [dokuwiki] Re: UTF-8 question
- » [dokuwiki] Re: UTF-8 question
- » [dokuwiki] Re: UTF-8 question
http://wiki.splitbrain.org/phpsnippets#decode_mail-subjects
-- DokuWiki mailing list - more info at http://wiki.splitbrain.org/wiki:mailinglist
- [dokuwiki] UTF-8 question
- From: Riny Heijdendael
- [dokuwiki] Re: UTF-8 question
- From: Andreas Gohr