O
O
Oleg Torbasov2010-11-03 13:21:04
Zend Framework
Oleg Torbasov, 2010-11-03 13:21:04

Zend_Filter_StringTrim not working correctly with UTF-8?

It turned out that the filter for string trimming, although it declares a "Unicode aware trim method", is not that "aware trim" after all. If it gets a string ending in the Cyrillic capital "R", it gets corrupted. Probably because its UTF-8 representation ends in A0.
Specifically, the problem comes up in this regular expression:
preg_replace('/^[\s]*|[\s]*$/sSD', '', $value)
If you add the u modifier, the result is generally NULL.
Nobody faced such a problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MT, 2010-11-04
@MTonly

PHP 5.2.10, 5.3.3 - Adding the u flag solves the problem. Regarding its absence, it makes sense to write a bug report .
By the way, the normal native PHP trim() function, when used without a second argument (or if there are no non-ASCII characters in it), is quite safe for UTF-8 strings.

A
Arsen, 2010-11-03
@mekegi

If you add the u modifier, the result is generally NULL.

just checked. with this modifier the regex works fine. without it, there really is a jamb with a capital P, but with it everything is OK
version of php - 5.3.1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question