diff --git a/html_to_text.inc b/html_to_text.inc index 4e7fc63..70b0fce 100644 --- a/html_to_text.inc +++ b/html_to_text.inc @@ -123,9 +123,8 @@ function mailsystem_html_to_text($string, $allowed_tags = NULL) { // Hard-wrap at 1000 characters (including the line break sequence) // and space-stuff special lines. $text = mailsystem_wrap_mail($text, array('max' => 1000 - strlen($eol), 'hard' => TRUE)); - // Change non-breaking spaces back to regular spaces, and trim line breaks. - // chr(160) is the non-breaking space character. - $text = str_replace(chr(160), ' ', trim($text, $eol)); + // Trim line breaks. + $text = trim($text, $eol); // Add footnotes; if ($notes) { // Add a blank line before the footnote list. @@ -170,8 +169,8 @@ function _mailsystem_html_to_text(DOMNode $node, array $allowed_tags, array &$no $text = preg_replace('/ *\r?\n/', $eol, $text); if (in_array('pre', $parents)) { // Within
 tags, all spaces become non-breaking.
-      // chr(160) is the non-breaking space character.
-      $text = str_replace(' ', chr(160), $text);
+      // 0xc2a0 is the UTF-8 encoded non-breaking space character (0xa0).
+      $text = str_replace(' ', chr(0xc2) . chr(0xa0), $text);
     }
     else {
       // Outside 
 tags, collapse whitespace.