ZF-11879: Zend_Locale_Format precision incorrect

Description

In Zend_Locale_Format the precision option seems to be broken for some locales. Here is an example in German:

echo Zend_Locale_Format::toNumber(53.3333333333333333333) returns 53,3333333333333333333

which is correct but

echo Zend_Locale_Format::toNumber(53.3333333333333333333, array('precision' => 1)) returns 533.333.333.333.330,0

which isn't even close.

This is seen on PHP 5.3.8 with BCMath enabled and ZF 1.11.11.

Comments

Drilling down a bit further it appears to be an interaction between PHP's setlocale() and ZF. Since we are in the process of migrating code from one to the other we are currently making use of both. It looks as if Zend_Locale_Format should be made aware of setlocale()'s settings.

After some team debugging the issue is the overuse of Zend_Locale_Math::normalize in toNumber. The first use is fine and handles the setlocale() case but then it is called over and over during the execution of toNumber. After the first call it strips the wrong decimal_point/thousands_sep and butchers the number resulting in the wrong output.