Fix: fatal hhvm error when outputting log messages in us-ascii charset
[plcapi.git] / src / Helper / Logger.php
index 0194765..bf86aba 100644 (file)
@@ -16,7 +16,7 @@ class Logger
     /**
      * This class is singleton, so that later we can move to DI patterns.
      *
-     * @return Charset
+     * @return Logger
      */
     public static function instance()
     {
@@ -37,6 +37,11 @@ class Logger
      */
     public function debugMessage($message, $encoding=null)
     {
+        // US-ASCII is a warning for PHP and a fatal for HHVM
+        if ($encoding == 'US-ASCII') {
+            $encoding = 'UTF-8';
+        }
+
         if (PHP_SAPI != 'cli') {
             $flags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE;
             if ($encoding != null) {