php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81449 NumberFormatter throws U_PARSE_ERROR on negative integer in ar & lt locales
Submitted: 2021-09-16 18:39 UTC Modified: 2021-09-17 14:28 UTC
Votes:8
Avg. Score:4.6 ± 0.7
Reproduced:5 of 6 (83.3%)
Same Version:5 (100.0%)
Same OS:5 (100.0%)
From: darius at frontu dot com Assigned: cmb (profile)
Status: Not a bug Package: intl (PECL)
PHP Version: 7.4.23 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: darius at frontu dot com
New email:
PHP Version: OS:

 

 [2021-09-16 18:39 UTC] darius at frontu dot com
Description:
------------
NumberFormatter does not work correctly only in lt & ar locales while trying to parse negative integers.

af int(-1)
af_NA int(-1)
af_ZA int(-1)
ak int(-1)
ak_GH int(-1)
sq int(-1)
sq_AL int(-1)
sq_XK int(-1)
sq_MK int(-1)
am int(-1)
am_ET int(-1)
ar bool(false)
ar_DZ bool(false)
ar_BH bool(false)
ar_KM bool(false)
ar_DJ bool(false)
ar_EG bool(false)
ar_ER bool(false)
ar_IQ bool(false)
ar_IL bool(false)
ar_YE bool(false)
ar_JO bool(false)
ar_QA bool(false)
ar_KW bool(false)
ar_LB bool(false)
ar_LY bool(false)
ar_MA bool(false)
ar_MR bool(false)
ar_OM bool(false)
ar_PS bool(false)
ar_SA bool(false)
ar_SY bool(false)
ar_SD bool(false)
ar_SO bool(false)
ar_SS bool(false)
ar_TD bool(false)
ar_TN bool(false)
ar_AE bool(false)
ar_EH bool(false)
...
ln_CG int(-1)
ln_CF int(-1)
lt bool(false)
lt_LT bool(false)
lu int(-1)
lu_CD int(-1)
lb int(-1)
lb_LU int(-1)


Test script:
---------------
$position = 0;
$formatter = new \NumberFormatter('lt', \NumberFormatter::DECIMAL);
$result = $formatter->parse(-1, \NumberFormatter::TYPE_INT64, $position);
var_dump($result);

Expected result:
----------------
int(-1)

Actual result:
--------------
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-09-17 13:01 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-09-17 13:01 UTC] cmb@php.net
This works for me with ICU 66.1.  Which ICU version are you using?
 [2021-09-17 13:02 UTC] cmb@php.net
See also <https://3v4l.org/145fl>.
 [2021-09-17 13:36 UTC] darius at frontu dot com
Might the problem, because ICU on machine is: 50.2
 [2021-09-17 14:28 UTC] cmb@php.net
-Status: Feedback +Status: Not a bug
 [2021-09-17 14:28 UTC] cmb@php.net
I checked with PHP 5.4.21 on Windows which has ICU 49.1.2, and
'lt' gives -1, but 'ar' gives FALSE, so this is most likely an ICU
issue.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC