smarty-php / smarty

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.
Other
2.26k stars 712 forks source link

Why strlen modifier not use mb_string? #1065

Open yourchoice opened 2 months ago

yourchoice commented 2 months ago

Why "strlen" modifier not use mb_strlen() instead of strlen() function ?

To have something like :

function smarty_modifier_strlen($string) {
    if (function_exists('mb_strlen')) {
        return mb_strlen($string);
    } else {
        return strlen($string);
    }
}
yourchoice commented 2 months ago

I see new StrlenModifierCompiler looks like:

class StrlenModifierCompiler extends Base {

    public function compile($params, \Smarty\Compiler\Template $compiler) {
        return 'strlen((string) ' . $params[0] . ')';
    }

}