library/smarty/libs/plugins/modifiercompiler.to_charset.php
changeset 0 4869aea77e21
equal deleted inserted replaced
-1:000000000000 0:4869aea77e21
       
     1 <?php
       
     2 /**
       
     3  * Smarty plugin
       
     4  *
       
     5  * @package    Smarty
       
     6  * @subpackage PluginsModifierCompiler
       
     7  */
       
     8 
       
     9 /**
       
    10  * Smarty to_charset modifier plugin
       
    11  * Type:     modifier<br>
       
    12  * Name:     to_charset<br>
       
    13  * Purpose:  convert character encoding from internal encoding to $charset
       
    14  *
       
    15  * @author Rodney Rehm
       
    16  *
       
    17  * @param array $params parameters
       
    18  *
       
    19  * @return string with compiled code
       
    20  */
       
    21 function smarty_modifiercompiler_to_charset($params) {
       
    22     if (!Smarty::$_MBSTRING) {
       
    23         // FIXME: (rodneyrehm) shouldn't this throw an error?
       
    24         return $params[0];
       
    25     }
       
    26 
       
    27     if (!isset($params[1])) {
       
    28         $params[1] = '"ISO-8859-1"';
       
    29     }
       
    30 
       
    31     return 'mb_convert_encoding(' . $params[0] . ', ' . $params[1] . ', "' . addslashes(Smarty::$_CHARSET) . '")';
       
    32 }