9731d160be67e10a9bc8791c4ec803d869b4bf05
2 /********************************************************************************
3 * include/wrapper.inc.php : text wrapper
4 * -------------------------
6 * This file is part of the banana distribution
7 * Copyright: See COPYING files that comes with this distribution
8 ********************************************************************************/
10 function wrap($_text, $_prefix="", $_length=72)
12 $parts = preg_split("/\n-- ?\n/", $_text);
13 if (count($parts) >1) {
14 $sign = "\n-- \n" . array_pop($parts);
15 $text = join("\n-- \n", $parts);
21 $cmd = "echo ".escapeshellarg($text)." | perl -MText::Autoformat -e 'autoformat {left=>1, right=>$_length, all=>1 };'";
24 return $_prefix.join("\n$_prefix", $result).($_prefix ?
'' : $sign);
27 function _headerdecode($charset, $c, $str) {
28 $s = ($c == 'Q') ?
quoted_printable_decode($str) : base64_decode($str);
29 $s = iconv($charset, 'iso-8859-15', $s);
30 return str_replace('_', ' ', $s);
33 function headerDecode($value) {
34 $val = preg_replace('/(=\?[^?]*\?[BQ]\?[^?]*\?=) (=\?[^?]*\?[BQ]\?[^?]*\?=)/', '\1\2', $value);
35 return preg_replace('/=\?([^?]*)\?([BQ])\?([^?]*)\?=/e', '_headerdecode("\1", "\2", "\3")', $val);