Issues

ZF-7175: Localization of number use 0xC2A0 instead [space] character

Description

Subj.

This problem block user input of localized numbers with spaces, bacause Zend_Locale_Format::isNumber return false on its.

Test:


$options = array(
    'locale' => 'ru'
);

$normalized = '1111'; // string(4) "1 111"
$localizedByMe = '1 111'; // string(5) "1 111"

$localizedByFilter = Zend_Locale_Format::toNumber($normalized, $options); // string(6) "1 111" - 6, not 5

for ($i=0; $i

Comments

This is not a failure. This locale, and also french for example, define that the separation must be done with a "non-breaking" space.

The reason behind this is simple:

Think of a number at the end of a line when usng a automated line break. The 1 would be at line 1, and the 111 would be at line 2. So for your user it would seem that you have 2 numbers.

So when using a space as separation, the given input will be recognised as 2 different numbers which, of course, means that false will be returned.

This is expected and correct behaviour.

When you have to work with localized userinput and want to convert spaces in non-breaking spaces, you should use for example a regex filter to change the character. Or your input field changes this itself.