Expanding on someone else's answer:
Using json_encode() requires:
- PHP 5.2.0 or greater
$myVarValue
encoded as UTF-8 (or US-ASCII, of course)
Since UTF-8 supports full Unicode, it should be safe to convert on the fly.
Note that because json_encode
escapes forward slashes, even a string that contains
will be escaped safely for printing with a script block.