UTF-8 fixes
[platal.git] / include / platal.inc.php
index 1d8d6b7..ae1a15c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
+ *  Copyright (C) 2003-2007 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -70,13 +70,13 @@ function pl_error_handler($errno, $errstr, $errfile, $errline)
     );
 
     global $globals;
-    if (!$globals->debug) {
+    if (isset($globals) && !$globals->debug) {
         if (strpos($errortype[$errno], 'Notice') !== false) {
             return;
         }
     }
 
-    $errstr = htmlentities($errstr);
+    $errstr = utf8_encode(htmlentities($errstr));
     $GLOBALS['pl_errors'][] =
         "<div class='phperror'>".
         "<strong>{$errortype[$errno]}</strong> <em>$errstr</em><br />".
@@ -131,5 +131,15 @@ function pl_redirect($path, $query = null, $fragment = null)
     http_redirect($globals->baseurl . '/' . pl_url($path, $query, $fragment));
 }
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+function pl_entities($text, $mode = ENT_COMPAT)
+{
+    return htmlentities($text, $mode, 'UTF-8');
+}
+
+function pl_entity_decode($text, $mode = ENT_COMPAT)
+{
+    return html_entity_decode($text, $mode, 'UTF-8');
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>