? config.php
Index: lib/html2text.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/html2text.php,v
retrieving revision 1.8.26.6
diff -u -r1.8.26.6 html2text.php
--- lib/html2text.php	22 May 2009 02:21:34 -0000	1.8.26.6
+++ lib/html2text.php	10 Jun 2009 03:04:16 -0000
@@ -30,6 +30,50 @@
  *                                                                       *
  *************************************************************************/
 
+/**
+ * Like html_entity_decode(,, 'UTF-8') except that it works in PHP4
+ * too.
+ *
+ * Function written by laurynas.butkus@gmail.com
+ *
+ * http://nz.php.net/manual/en/function.html-entity-decode.php#75153
+ */
+function html_entity_decode_utf8($string)
+{
+    static $trans_tbl;
+   
+    // replace numeric entities
+    $string = preg_replace('~&#x([0-9a-f]+);~ei', 'code2utf(hexdec("\\1"))', $string);
+    $string = preg_replace('~&#([0-9]+);~e', 'code2utf(\\1)', $string);
+
+    // replace literal entities
+    if (!isset($trans_tbl))
+    {
+        $trans_tbl = array();
+       
+        foreach (get_html_translation_table(HTML_ENTITIES) as $val=>$key)
+            $trans_tbl[$key] = utf8_encode($val);
+    }
+   
+    return strtr($string, $trans_tbl);
+}
+
+/**
+ * Returns the utf string corresponding to the unicode value
+ * 
+ * Function written by romans@void.lv
+ *
+ * http://nz.php.net/manual/en/function.html-entity-decode.php#75153
+ */
+function code2utf($num)
+{
+    if ($num < 128) return chr($num);
+    if ($num < 2048) return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
+    if ($num < 65536) return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
+    if ($num < 2097152) return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
+    return '';
+}
+
 
 /**
  *  Takes HTML and converts it to formatted, plain text.
@@ -471,7 +515,7 @@
         $text = preg_replace_callback($this->callback_search, array(&$this, '_preg_callback'), $text);
 
         // Replace known html entities
-        $text = utf8_encode(html_entity_decode($text));
+        $text = html_entity_decode_utf8($text);
 
         // Remove unknown/unhandled entities (this cannot be done in search-and-replace block)
         $text = preg_replace('/&[^&;]+;/i', '', $text); 
