summaryrefslogtreecommitdiff
path: root/itjs.class
diff options
context:
space:
mode:
authorThomas BrĂ¼derli2007-08-27 08:35:43 +0000
committerThomas BrĂ¼derli2007-08-27 08:35:43 +0000
commitb08a2b29fd69cc8f5b22eabc830281f38b821c1b (patch)
tree38700182681351ef6d7c60b6ab07b6514afe6436 /itjs.class
parent1e33a118a88fff5684d388ead9aec3dca7e0bcf6 (diff)
downloaditools-b08a2b29fd69cc8f5b22eabc830281f38b821c1b.tar.gz
itools-b08a2b29fd69cc8f5b22eabc830281f38b821c1b.tar.bz2
itools-b08a2b29fd69cc8f5b22eabc830281f38b821c1b.zip
Encode all non-ascii chars in js data
Diffstat (limited to 'itjs.class')
-rw-r--r--itjs.class2
1 files changed, 1 insertions, 1 deletions
diff --git a/itjs.class b/itjs.class
index edc0d33..c0a8ef3 100644
--- a/itjs.class
+++ b/itjs.class
@@ -72,7 +72,7 @@ function encode($values)
else if (!is_array($value))
{
$quote = (strval(intval($value)) === strval($value)) ? "" : '"';
- $result .= $quote . strtr($value, array("\0" => '\\0', '"' => '\\"', "</"=>"<\\/", "\n" => '\\n', "\r" => '\\r', "\t" => '\\t', "\\" => '\\\\')) . $quote;
+ $result .= $quote . preg_replace('/([\xa0-\xff])/e', 'sprintf("\\x%02x", ord("\\1"))', strtr($value, array("\0" => '\\0', '"' => '\\"', "</"=>"<\\/", "\n" => '\\n', "\r" => '\\r', "\t" => '\\t', "\\" => '\\\\'))) . $quote;
}
else
$result .= itjs::encode($value);