From 74ae8849ddffd90172a5f62cbc32469463473eb8 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sun, 09 Sep 2007 14:04:54 -0400
Subject: [PATCH] Fixed charset encoding bug (#1484429)

---
 CHANGELOG                |    1 +
 program/include/main.inc |    7 +------
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index eccf256..2ebe78b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
 
 2007/09/09 (thomasb)
 ----------
+- Fixed charset encoding bug (#1484429)
 - Applied patch for LDAP version (#1484552)
 - Improved XHTML validation
 
diff --git a/program/include/main.inc b/program/include/main.inc
index 0d06203..854458a 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -1123,10 +1123,6 @@
   if (!$enctype)
     $enctype = $GLOBALS['OUTPUT_TYPE'];
 
-  // convert nbsps back to normal spaces if not html
-  if ($enctype!='html')
-    $str = str_replace(chr(160), ' ', $str);
-
   // encode for plaintext
   if ($enctype=='text')
     return str_replace("\r\n", "\n", $mode=='remove' ? strip_tags($str) : $str);
@@ -1171,11 +1167,10 @@
 
     for ($c=160; $c<256; $c++)  // can be increased to support more charsets
       {
-      $hex = dechex($c);
       $xml_rep_table[Chr($c)] = "&#$c;";
       
       if ($OUTPUT->get_charset()=='ISO-8859-1')
-        $js_rep_table[Chr($c)] = sprintf("\u%s%s", str_repeat('0', 4-strlen($hex)), $hex);
+        $js_rep_table[Chr($c)] = sprintf("\\u%04x", $c);
       }
 
     $xml_rep_table['"'] = '&quot;';

--
Gitblit v1.9.1