Skip to content

Commit

Permalink
Encoder: encodes strings with JSON_UNESCAPED_UNICODE | JSON_UNESCAPED…
Browse files Browse the repository at this point in the history
…_SLASHES
  • Loading branch information
dg committed Jan 4, 2015
1 parent 6b2b821 commit 6a0ac32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Neon/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function encode($var, $options = NULL)
return strpos($var, '.') === FALSE ? $var . '.0' : $var;

} else {
return json_encode($var);
return json_encode($var, PHP_VERSION_ID >= 50400 ? JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES : 0);
}
}

Expand Down
5 changes: 5 additions & 0 deletions tests/Neon/Encoder.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,8 @@ Assert::same(
'ent()',
Neon::encode($entity)
);

Assert::same(
PHP_VERSION_ID >= 50400 ? '",žlu/ťoučký"' : '",\u017elu\/\u0165ou\u010dk\u00fd"',
Neon::encode(',žlu/ťoučký')
);

0 comments on commit 6a0ac32

Please sign in to comment.