From 6a0ac32bd931887769d827778f974f009cb7fc84 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 5 Jan 2015 00:08:10 +0100 Subject: [PATCH] Encoder: encodes strings with JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES --- src/Neon/Encoder.php | 2 +- tests/Neon/Encoder.phpt | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Neon/Encoder.php b/src/Neon/Encoder.php index f640000b..c47e918f 100644 --- a/src/Neon/Encoder.php +++ b/src/Neon/Encoder.php @@ -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); } } diff --git a/tests/Neon/Encoder.phpt b/tests/Neon/Encoder.phpt index 2b7afd12..8a8c28ae 100644 --- a/tests/Neon/Encoder.phpt +++ b/tests/Neon/Encoder.phpt @@ -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ý') +);