php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25246 broken locale support for decimal_point
Submitted: 2003-08-26 05:04 UTC Modified: 2003-08-27 07:21 UTC
From: david at boe dot es Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.2 OS: linux
Private report: No CVE-ID: None
 [2003-08-26 05:04 UTC] david at boe dot es
Description:
------------
As stated in http://bugs.php.net/bug.php?id=17079 and http://news.php.net/article.php?group=php.dev&article=95211 , PHP always resets decimal_point to "." besides your locale "decimal_point".

This breaks backward compatibility, at least with PHP 4.2.3

This is BAD as long as we use na Oracle database with NLS_LANG=Spanish_Spain.WE8ISO8859P1 , needed to output regional chars like ? and ?????. This means that all operations with numerical values returned by a database query (decimal part separated by ',') are broken now.

In my linux:

[root@farm2 root]# export LANG=es_ES
[root@farm2 root]# locale -k decimal_point
decimal_point=","

The script:

<?php

setlocale(LC_ALL, 'es_ES');
$locale_info = localeconv();
echo "decimal_point:   {$locale_info["decimal_point"]}\n";
$value1="1.5";
$value2="1,5";
$res1=$value1*1;
$res2=$value2*1;
echo "Res 1 : $res1 \n";
echo "Res 2 : $res2 \n";

?>

outputs:

decimal_point:   .
Res 1 : 1,5
Res 2 : 1


Reproduce code:
---------------
In my linux:

[root@farm2 root]# export LANG=es_ES
[root@farm2 root]# locale -k decimal_point
decimal_point=","

The script:

<?php

setlocale(LC_ALL, 'es_ES');
$locale_info = localeconv();
echo "decimal_point:   {$locale_info["decimal_point"]}\n";
$value1="1.5";
$value2="1,5";
$res1=$value1*1;
$res2=$value2*1;
echo "Res 1 : $res1 \n";
echo "Res 2 : $res2 \n";

?>

outputs:

decimal_point:   .
Res 1 : 1,5
Res 2 : 1



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-26 05:08 UTC] sniper@php.net
For the same reason as stated before in the urls you gave.

 [2003-08-27 07:21 UTC] david at boe dot es
Hi!

I'm sorry about the bogus status of my recent submission, but i think that you are not carefully considering this problem. The problem was not considered a bug sometime ago, but that doesn't mean it isn't.

I've read severak times the reasons you mention, and i think the solution is not correct. The reason given a year ago was:

You should not use ',' to represent floats ALWAYS use '.' regardless of
locale.

This is not a genuine reason, just because, databases returns their values in locale format (1,5 instead of 1.5). There is not a workaround solution for applications manipulating those values (maybe an oci8 function returning floats always with ".").

Please, consider this problem as a real one, because, it will make us stick with older versions of php that respect the locale output returned from Oracle.

Thanks for any help.

Yours,
David.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Mon Feb 02 03:00:01 2026 UTC