From 4baf602eabccf7d9a3ee11fbbc1db01b9be1cb03 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 6 Apr 2010 00:53:32 -0400 Subject: [PATCH] Updated default character escaping for UTF-8 compatibility. For other character sets, or to disable UTF-8 support entirely, change the 'charset' property or renderEscaped method on subclasses. --- Mustache.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Mustache.php b/Mustache.php index 578d060..d8d42f6 100644 --- a/Mustache.php +++ b/Mustache.php @@ -22,6 +22,9 @@ class Mustache { protected $throwPartialExceptions = false; protected $throwVariableExceptions = false; + // Override charset passed to htmlentities() and htmlspecialchars(). Defaults to UTF-8. + protected $charset = 'UTF-8'; + protected $tagRegEx; protected $template = ''; @@ -232,7 +235,7 @@ class Mustache { * @return string */ protected function renderEscaped($tag_name, &$context) { - return htmlentities($this->getVariable($tag_name, $context)); + return htmlentities($this->getVariable($tag_name, $context), null, $this->charset); } /**