new tests wrt encodings
[banana.git] / banana / misc.inc.php
index a72e6cf..9510b14 100644 (file)
 
 function _b_($str) { return utf8_decode(dgettext('banana', utf8_encode($str))); }
 
+function to_entities($str) {
+    require_once 'banana/utf8.php';
+    return utf8entities(htmlentities($str, ENT_NOQUOTES, 'UTF-8'));
+}
+
 /********************************************************************************
  *  HEADER STUFF
  */
@@ -201,7 +206,7 @@ function wrap($text, $_prefix="")
 }
 
 function formatbody($_text) {
-    $res  = "\n\n" . htmlentities(wrap($_text, ""))."\n\n";
+    $res  = "\n\n" . to_entities(wrap($_text, ""))."\n\n";
     $res  = preg_replace("/(<|>|")/", " \\1 ", $res);
     $res  = preg_replace('/(["\[])?((https?|ftp|news):\/\/[a-z@0-9.~%$£µ&i#\-+=_\/\?]*)(["\]])?/i', "\\1<a href=\"\\2\">\\2</a>\\4", $res);
     $res  = preg_replace("/ (&lt;|&gt;|&quot;) /", "\\1", $res);