Skip to content

Commit 6a0ac32

Browse files
committed
Encoder: encodes strings with JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
1 parent 6b2b821 commit 6a0ac32

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Neon/Encoder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function encode($var, $options = NULL)
7777
return strpos($var, '.') === FALSE ? $var . '.0' : $var;
7878

7979
} else {
80-
return json_encode($var);
80+
return json_encode($var, PHP_VERSION_ID >= 50400 ? JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES : 0);
8181
}
8282
}
8383

tests/Neon/Encoder.phpt

+5
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,8 @@ Assert::same(
7272
'ent()',
7373
Neon::encode($entity)
7474
);
75+
76+
Assert::same(
77+
PHP_VERSION_ID >= 50400 ? '",žlu/ťoučký"' : '",\u017elu\/\u0165ou\u010dk\u00fd"',
78+
Neon::encode(',žlu/ťoučký')
79+
);

0 commit comments

Comments
 (0)