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

Locale insensitive float format #68

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"require": {
"php": "^7.4 || ^8.0",
"ext-dom": "*",
"ext-libxml": "*"
"ext-libxml": "*",
"ext-intl": "*"
},
"authors": [
{
Expand Down
11 changes: 8 additions & 3 deletions src/CFPropertyList/CFNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
namespace CFPropertyList;

use \DOMDocument;
use \Iterator;
use \ArrayAccess;
use \NumberFormatter;

/**
* Number Type of CFPropertyList
Expand All @@ -68,7 +67,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