php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71979 NumberFormatter add Non-breaking Space into Numbers
Submitted: 2016-04-06 14:17 UTC Modified: 2016-04-11 13:13 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: timo dot tewes at celexongroup dot com Assigned:
Status: Not a bug Package: intl (PECL)
PHP Version: 5.6.20 OS: Ubuntu 14.04
Private report: No CVE-ID: None
 [2016-04-06 14:17 UTC] timo dot tewes at celexongroup dot com
Description:
------------
When a Number with more than 3 characters is formatted with the NumberFormatter, a non-breaking Space is added after the white space in locale Poland.

This isn't always visible, but can be seen with a hex Editor:
Expected Result:
1090663 -> '1 090 663' -> 1 090 663
PHP Result:
1090633 -> '1 090 663' -> 1 090 663

Working example can be seen here: https://3v4l.org/B6lck


Test script:
---------------
<?php

$formatter = NumberFormatter::create('PL', NumberFormatter::DECIMAL);

$result = $formatter->format(1090663, NumberFormatter::TYPE_DOUBLE);
echo $result . ' = ' . bin2hex($result) . PHP_EOL;
echo '1 090 663' . ' = ' . bin2hex('1 090 663') . PHP_EOL;

Expected result:
----------------
1 090 663 = 312030393020363633
1 090 663 = 312030393020363633

Actual result:
--------------
1 090 663 = 31c2a0303930c2a0363633
1 090 663 = 312030393020363633

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-07 10:02 UTC] timo dot tewes at celexongroup dot com
This is actually not a bug. It makes sense that numbers are not wrapped at the end of a line.

So this issue can be closed.
 [2016-04-11 13:13 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2016-04-11 13:13 UTC] ab@php.net
Same behavior is actually with MessageFormatter and othes. It depends on the concrete locale which thousand/decimal separators are used.

Thanks.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Apr 03 20:01:23 2020 UTC