ID:               28057
 Updated by:       php-bugs@lists.php.net
 Reported By:      bublavas at ecetra dot com
-Status:           Feedback
+Status:           No Feedback
 Bug Type:         Strings related
 Operating System: 2.4.21-9.EL GNU/Linux
 PHP Version:      4.3.6
 New Comment:

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".


Previous Comments:
------------------------------------------------------------------------

[2005-02-03 05:35:47] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip



------------------------------------------------------------------------

[2004-04-23 11:42:25] phpdev at martinsojka dot de

Bugfix @ http://www.martinsojka.de/patches/php-4.3.6-bug28057.patch

This one is of the "works for me" kind. It needs at least a check for
ENOMEM where strdup() is used, but I don't know enough of PHP's
internal error handling to add that quickly.

Test:

<?php
echo "Default locale:\n";
echo "serialized 0.25: \"", serialize(2.5e-1), "\", ";
echo "thousands separator: \"", nl_langinfo(THOUSEP), "\", ";
echo "decimal point: \"", nl_langinfo(RADIXCHAR), "\"\n";
if ( setlocale(LC_ALL, 'de_DE') )
{
    echo "de_DE locale:\n";
    echo "BEFORE serialize, ";
    echo "thousands separator: \"", nl_langinfo(THOUSEP), "\", ";
    echo "decimal point: \"", nl_langinfo(RADIXCHAR), "\"\n";
    echo "serialized 0.25: \"", serialize(2.5e-1), "\", ";
    echo "thousands separator: \"", nl_langinfo(THOUSEP), "\", ";
    echo "decimal point: \"", nl_langinfo(RADIXCHAR), "\"\n";
}
else
{
    echo "cannot set locale to de_DE", "\n";
}
?>

Expected output:

Default locale:
serialized 0.25: "d:0.25;", thousands separator: "", decimal point:
"."
de_DE locale:
BEFORE serialize, thousands separator: ".", decimal point: ","
serialized 0.25: "d:0.25;", thousands separator: ".", decimal point:
","

... or:

Default locale:
serialized 0.25: "d:0.25;", thousands separator: "", decimal point:
"."
cannot set locale to de_DE

------------------------------------------------------------------------

[2004-04-19 15:38:52] bublavas at ecetra dot com

Hmm, shouldn't this hack be in serialize() then? Do you know a 
workaround that I can use?

------------------------------------------------------------------------

[2004-04-19 15:13:27] [EMAIL PROTECTED]

No, the problem is in setlocale().
When you set LC_NUMERIC or LC_ALL and the decimal point is not '.',
then LC_NUMERIC is set back to "C" again.
This hack is required for serialize() when handling floating point
numbers.

------------------------------------------------------------------------

[2004-04-19 14:28:22] bublavas at ecetra dot com

Description:
------------
nl_langinfo returns wrong values for THOUSEP and RADIXCHAR after
setting the locale to 'de_DE'. Using localeconv() returns the same
wrong values.

An equivalent C program returns correct results.

PHP 4.3.4 returns the same results as 4.3.6; executing the script from
the command line vs. using HTTP (Apache 2.0.48) makes no difference as
well.

Reproduce code:
---------------
if ( setlocale(LC_ALL, 'de_DE') )
{
    echo "thousands separator: ", nl_langinfo(THOUSEP), "\n";
    echo "decimal point: ", nl_langinfo(RADIXCHAR), "\n";
}
else
{
    echo "cannot set locale to de_DE", "\n";
}


Expected result:
----------------
thousands separator: .
decimal point: ,

Actual result:
--------------
thousands separator:
decimal point: .


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=28057&edit=1

Reply via email to