replace htmlentities() with htmlentities_utf8()
[acontent.git] / docs / include / vitals.inc.php
index 2b422d2..85c9f39 100644 (file)
@@ -400,6 +400,22 @@ function get_default_theme() {
                return $rows[0]['dir_name'];
 }
 
+/**
+ * Convert all input to htmlentities output, in UTF-8.
+ * @param      string  input to be convert
+ * @param      boolean true if we wish to change all newlines(\r\n) to a <br/> tag, false otherwise.  
+ *                     ref: http://php.net/manual/en/function.nl2br.php
+ * @author     Harris Wong
+ * @date       March 12, 2010
+ */
+function htmlentities_utf8($str, $use_nl2br=true){
+       $return = htmlentities($str, ENT_QUOTES, 'UTF-8');
+       if ($use_nl2br){
+               return nl2br($return);
+       } 
+       return $return;
+}
+
 /**
  * Convert all '&' to '&amp;' from the input
  * @param   string  any string input, mainly URLs.