php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78068 Intl extension getTextAttribute incorrect result
Submitted: 2019-05-26 10:47 UTC Modified: 2019-05-26 17:05 UTC
From: shariefjamiel at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: intl (PECL)
PHP Version: 7.2.18 OS: ubuntu 18.04 - php 7.2.15
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: shariefjamiel at gmail dot com
New email:
PHP Version: OS:

 

 [2019-05-26 10:47 UTC] shariefjamiel at gmail dot com
Description:
------------
I am trying to use the Number formatter to get information but the get text attribute is returning strange results.

Test script:
---------------
setlocale(LC_ALL,'en_GB');
Locale::setDefault('en_GB');
$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);

// This should be currency symbol but result is null
$result = $formatter->getTextAttribute(NumberFormatter::CURRENCY_SYMBOL);

// This should be decimal sperator, but its the currency symbol
$result = $formatter->getTextAttribute(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL)

Expected result:
----------------
// This should be currency symbol but result is null
echo $formatter->getTextAttribute(NumberFormatter::CURRENCY_SYMBOL); // £

// This should be decimal sperator, but its the currency symbol
echo $formatter->getTextAttribute(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL); // .

Actual result:
--------------
// This should be currency symbol but result is null
echo $formatter->getTextAttribute(NumberFormatter::CURRENCY_SYMBOL); // NULL

// This should be decimal sperator, but its the currency symbol
echo $formatter->getTextAttribute(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL); // £

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-26 12:00 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Package: Date/time related +Package: intl -Assigned To: +Assigned To: cmb
 [2019-05-26 12:00 UTC] cmb@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

What you are actually looking for is NumberFormatter::getSymbol(),
see <https://3v4l.org/ZIU9I>.
 [2019-05-26 17:05 UTC] shariefjamiel at gmail dot com
Sorry my bad. You can close this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 09:01:29 2024 UTC