diff options
Diffstat (limited to 'program/include')
-rw-r--r-- | program/include/rcube_bc.inc | 4 | ||||
-rw-r--r-- | program/include/rcube_mime.php | 18 |
2 files changed, 15 insertions, 7 deletions
diff --git a/program/include/rcube_bc.inc b/program/include/rcube_bc.inc index 1894873e6..4130d4dc5 100644 --- a/program/include/rcube_bc.inc +++ b/program/include/rcube_bc.inc @@ -338,9 +338,9 @@ function show_bytes($bytes) return rcmail::get_instance()->show_bytes($bytes); } -function rc_wordwrap($string, $width=75, $break="\n", $cut=false) +function rc_wordwrap($string, $width=75, $break="\n", $cut=false, $charset=null) { - return rcube_mime::wordwrap($string, $width, $break, $cut); + return rcube_mime::wordwrap($string, $width, $break, $cut, $charset); } function rc_request_header($name) diff --git a/program/include/rcube_mime.php b/program/include/rcube_mime.php index 2dbeaf67a..ac3ef9e8a 100644 --- a/program/include/rcube_mime.php +++ b/program/include/rcube_mime.php @@ -529,10 +529,11 @@ class rcube_mime * * @param string $text Text to wrap * @param int $length Length + * @param string $charset Character encoding of $text * * @return string Wrapped text */ - public static function format_flowed($text, $length = 72) + public static function format_flowed($text, $length = 72, $charset=null) { $text = preg_split('/\r?\n/', $text); @@ -542,10 +543,10 @@ class rcube_mime $prefix = $regs[0]; $level = strlen($prefix); $line = rtrim(substr($line, $level)); - $line = $prefix . self::wordwrap($line, $length - $level - 2, " \r\n$prefix "); + $line = $prefix . self::wordwrap($line, $length - $level - 2, " \r\n$prefix ", false, $charset); } else if ($line) { - $line = self::wordwrap(rtrim($line), $length - 2, " \r\n"); + $line = self::wordwrap(rtrim($line), $length - 2, " \r\n", false, $charset); // space-stuffing $line = preg_replace('/(^|\r\n)(From| |>)/', '\\1 \\2', $line); } @@ -565,12 +566,16 @@ class rcube_mime * @param int $width Line width * @param string $break Line separator * @param bool $cut Enable to cut word + * @param string $charset Charset of $string * * @return string Text */ - public static function wordwrap($string, $width=75, $break="\n", $cut=false) + public static function wordwrap($string, $width=75, $break="\n", $cut=false, $charset=null) { - $para = explode($break, $string); + if ($charset) + mb_internal_encoding($charset); + + $para = preg_split('/\r?\n/', $string); $string = ''; while (count($para)) { @@ -624,6 +629,9 @@ class rcube_mime } } + if ($charset) + mb_internal_encoding(RCMAIL_CHARSET); + return $string; } |