Bug #76435 [NEW]: Float with decimals Filter issue with Ca_fr locale
| From: | joel dot lamothe dot 42 at gmail dot com | Date: | Sat, 09 Jun 2018 00:29:31 +0000 |
| Subject: | Bug #76435 [NEW]: Float with decimals Filter issue with Ca_fr locale | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-215554@lists.php.net to get a copy of this message | ||
From: joel dot lamothe dot 42 at gmail dot com
Operating system: Windows
PHP version: 7.1.18
Package: Filter related
Bug Type: Bug
Bug description:Float with decimals Filter issue with Ca_fr locale
Description:
------------
---
From manual page: http://www.php.net/filter.filters.sanitize
---
When setting the locale to fr_CA, using filter_var with decimal numbers
is behaving irregularly since the comma is the decimal separator in
fr_CA, the sanitized float becomes an int losing its comma.
filter_var is either not coded in a locale dependent way or this below
scenario is not being caught in its handling of the locale.
Test script:
---------------
<?php
setlocale(LC_ALL, 'fr_CA.utf-8');
$number = 25 / 2;
$temp = filter_var($number, FILTER_SANITIZE_NUMBER_FLOAT,
FILTER_FLAG_ALLOW_FRACTION);
echo $temp;
?>
Expected result:
----------------
12,5
Actual result:
--------------
125
--
Edit bug report at https://bugs.php.net/bug.php?id=76435&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76435&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76435&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76435&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76435&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76435&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76435&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76435&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76435&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76435&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76435&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76435&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76435&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76435&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76435&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76435&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76435&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76435&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76435&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76435&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76435&r=mysqlcfg