ZF-7023: Zend_Filter_StringTrim does not work correctly with a multibyte string


Zend_Filter_StringTrim uses trim(), so there are two problems. - It does not filter the characters like U+0085 next line and U+00A0 no-break space. -- You can use preg_match('/^[\s\p{Zs}\p{Zl}\p{Zp}]+$/u', $str) to see what characters are white spaces in UTF-8. - If the trim_charlist parameter includes multibyte characters, it does not work as expected. -- The returned string is cut in the middle of the multibyte character.

$trim_charlist = " \t\n\r\0\x0B・。"; $filter = new Zend_Filter(); $filter->addFilter(new Zend_Filter_StringTrim($trim_charlist)); $s = $filter->filter($value);

There is neither mb_trim() function or iconv_trim function in php core. We need to trim with preg_replace or something. @see…


Changed to improvement as even PHP itself does not support this feature

Feature enhancement added with r16191