Bug #68203 [Opn]: implode() for foat numbers use setlocale() settings!
| From: | i dot am dot brutto at gmail dot com | Date: | Fri, 10 Oct 2014 08:05:13 +0000 |
| Subject: | Bug #68203 [Opn]: implode() for foat numbers use setlocale() settings! | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187998@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68203&edit=1
ID: 68203
User updated by: i dot am dot brutto at gmail dot com
Reported by: i dot am dot brutto at gmail dot com
Summary: implode() for foat numbers use setlocale() settings!
Status: Open
Type: Bug
Package: Strings related
Operating System: Ubuntu
PHP Version: 5.5.17
Block user comment: N
Private report: N
New Comment:
Cris,
reproduced on my Ubuntu 12.04(LTS) with PHP 5.5.15-1+deb.sury.org~precise+1 (cli) (built: Jul 24
2014 15:44:50) and PHP 5.5.17-2+deb.sury.org~precise+1 (cli) (built: Sep 25 2014 09:07:54)
Btw, check your installed locales via
locale -a. RU locale must be installed.
Previous Comments:
------------------------------------------------------------------------
[2014-10-10 03:51:21] chris at ctankersley dot com
Created a test for this:
--TEST--
implode() function - Floats use locale settings
--FILE--
<?php
$locale = 'ru_RU';
putenv("LANG=$locale" . '.UTF-8');
putenv("LANGUAGE=$locale" . '.UTF-8');
setlocale(LC_ALL, $locale . '.UTF-8'); // . '.UTF-8'
$arr = array(12.12,12,23,21.44,67.88);
print_r(implode(',', $arr));
--EXPECT--
12.12,12,23,21.44,67.88
From my end though, I couldn't seem to reproduce this. I tested this on a Windows build of
7.0.0-dev and on Ubuntu using their 5.5.9 package. 3v4l.org also shows that this works properly: http://3v4l.org/DpnLh
------------------------------------------------------------------------
[2014-10-09 22:54:23] i dot am dot brutto at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.implode
---
There is no any information aboout this strange behavior. =\
Detect this was difficult enough because do not expect problems in such simple core things.
It's the same bug (https://bugs.php.net/bug.php?id=17815), but it dodn't fixed (as there
marked).
Test script:
---------------
<?php
$locale = 'ru_RU';
putenv("LANG=$locale" . '.UTF-8');
putenv("LANGUAGE=$locale" . '.UTF-8');
setlocale(LC_ALL, $locale . '.UTF-8'); // . '.UTF-8'
$arr = array(12.12,12,23,21.44,67.88);
print_r(implode(',', $arr));
Expected result:
----------------
there is no logic. other string functions not affected with this. and nowhere information about it.
$arr = array(12.12,12,23,21.44,67.88);
print_r(implode(' | ', $arr));
expected => 12.12 | 12 | 23 | 21.44 | 67.88
current => 12,12 | 12 | 23 | 21,44 | 67,88 (setlocale to ru_RU for example)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68203&edit=1