Handle LC_NUMERIC with comma decimal separator

Closes #399.
This commit is contained in:
Nikita Popov 2017-07-19 17:10:55 +02:00
parent 4a7d011317
commit 5a3a1ec25c

View File

@ -182,6 +182,11 @@ class Standard extends PrettyPrinterAbstract
$stringValue = sprintf('%.17G', $node->value);
}
// %G is locale dependent and there exists no locale-independent alternative. We don't want
// mess with switching locales here, so let's assume that a comma is the only non-standard
// decimal separator we may encounter...
$stringValue = str_replace(',', '.', $stringValue);
// ensure that number is really printed as float
return preg_match('/^-?[0-9]+$/', $stringValue) ? $stringValue . '.0' : $stringValue;
}