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

Issue Type: Improvement Created: 2009-06-16T00:42:10.000+0000 Last Updated: 2009-06-20T14:22:23.000+0000 Status: Resolved Fix version(s): - 1.9.0 (31/Jul/09)

Reporter: twk (twk) Assignee: Thomas Weidner (thomas) Tags: - Zend_Filter

Related issues: Attachments:


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…


Posted by Thomas Weidner (thomas) on 2009-06-20T14:19:20.000+0000

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

Posted by Thomas Weidner (thomas) on 2009-06-20T14:22:23.000+0000

Feature enhancement added with r16191

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.