Permalink
Browse files

[Yaml] fixed dumper for floats when the locale separator is not a dot

  • Loading branch information...
1 parent 06b80fa commit 21cb2c0816ce88e794cc59f8401c10b73ef5c76c @fabpot fabpot committed Nov 4, 2011
Showing with 11 additions and 1 deletion.
  1. +11 −1 Inline.php
View
@@ -87,7 +87,17 @@ static public function dump($value)
case ctype_digit($value):
return is_string($value) ? "'$value'" : (int) $value;
case is_numeric($value):
- return is_string($value) ? "'$value'" : (is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : $value);
+ $locale = setlocale(LC_NUMERIC, 0);
+ if (false !== $locale) {
+ setlocale(LC_NUMERIC, 'C');
+ }
+ $repr = is_string($value) ? "'$value'" : (is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : strval($value));
+
+ if (false !== $locale) {
+ setlocale(LC_NUMERIC, $locale);
+ }
+
+ return $repr;
case Escaper::requiresDoubleQuoting($value):
return Escaper::escapeWithDoubleQuotes($value);
case Escaper::requiresSingleQuoting($value):

0 comments on commit 21cb2c0

Please sign in to comment.