Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
fix(CFNumber): locale insensitive float format
Browse files Browse the repository at this point in the history
CFNumber must output floats with dot as decimal separator
This change forces a 10 digits limit after the decimal separator

Signed-off-by: Thierry Bugier <[email protected]>
  • Loading branch information
btry committed Jun 4, 2021
1 parent d3b5376 commit 1bf103c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/CFPropertyList/CFNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ public function toXML(DOMDocument $doc, $nodeName = "")
$this->value = intval($this->value);
$ret = 'integer';
}
return parent::toXML($doc, $ret);
$formatter = new \NumberFormatter('en_US', \NumberFormatter::DECIMAL);
$formatter->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, 10);
$formatter->setAttribute(\NumberFormatter::GROUPING_USED, false);
$text = $doc->createTextNode($formatter->format($this->value));
$node = $doc->createElement($ret);
$node->appendChild($text);
return $node;
}

/**
Expand Down

0 comments on commit 1bf103c

Please sign in to comment.