smarty icon indicating copy to clipboard operation
smarty copied to clipboard

Why strlen modifier not use mb_string?

Open yourchoice opened this issue 1 year ago • 1 comments

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 avatar Sep 13 '24 08:09 yourchoice

I see new StrlenModifierCompiler looks like:

class StrlenModifierCompiler extends Base {

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

}

yourchoice avatar Sep 13 '24 10:09 yourchoice