function twig_upper_filter(Twig_Environment $env, $string)
{
- if (!is_null($env->getCharset())) {
- return mb_strtoupper($string, $env->getCharset());
+ if (!is_null($charset = $env->getCharset())) {
+ return mb_strtoupper($string, $charset);
}
return strtoupper($string);
function twig_lower_filter(Twig_Environment $env, $string)
{
- if (!is_null($env->getCharset())) {
- return mb_strtolower($string, $env->getCharset());
+ if (!is_null($charset = $env->getCharset())) {
+ return mb_strtolower($string, $charset);
}
return strtolower($string);
function twig_title_string_filter(Twig_Environment $env, $string)
{
- if (is_null($env->getCharset())) {
- return ucwords(strtolower($string));
+ if (!is_null($charset = $env->getCharset())) {
+ return mb_convert_case($string, MB_CASE_TITLE, $charset);
}
- return mb_convert_case($string, MB_CASE_TITLE, $env->getCharset());
+ return ucwords(strtolower($string));
}
function twig_capitalize_string_filter(Twig_Environment $env, $string)
{
- if (is_null($env->getCharset())) {
- return ucfirst(strtolower($string));
+ if (!is_null($charset = $env->getCharset())) {
+ return mb_strtoupper(mb_substr($string, 0, 1, $charset)).
+ mb_strtolower(mb_substr($string, 1, mb_strlen($string), $charset), $charset);
}
- return mb_strtoupper(mb_substr($string, 0, 1, $env->getCharset())).
- mb_strtolower(mb_substr($string, 1, mb_strlen($string), $env->getCharset()), $env->getCharset());
+ return ucfirst(strtolower($string));
}
}
// and byte fallback