summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
authorctrlaltca@gmail.com <>2011-06-25 12:23:51 +0000
committerctrlaltca@gmail.com <>2011-06-25 12:23:51 +0000
commitf5a87398433ebecefbc62d4fead8a178e32a1f26 (patch)
treef4b965f670b3dc6b4d8049166bc9dab60fff1f84 /framework/Web
parent9db33e4243eb5aa50a3cc18673cc09565acd502a (diff)
reapplied patch for #106 since it seems like it's playing fine now.
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/Javascripts/TJavaScript.php12
1 files changed, 12 insertions, 0 deletions
diff --git a/framework/Web/Javascripts/TJavaScript.php b/framework/Web/Javascripts/TJavaScript.php
index 2efbea3a..2df16816 100644
--- a/framework/Web/Javascripts/TJavaScript.php
+++ b/framework/Web/Javascripts/TJavaScript.php
@@ -237,6 +237,15 @@ class TJavaScript
*/
public static function jsonEncode($value)
{
+ if (function_exists('json_encode'))
+ {
+ if (is_string($value) &&
+ ($g=Prado::getApplication()->getGlobalization(false))!==null &&
+ strtoupper($enc=$g->getCharset())!='UTF-8')
+ $value=iconv($enc, 'UTF-8', $value);
+ return json_encode($value);
+ }
+
if(self::$_json === null)
self::$_json = Prado::createComponent('System.Web.Javascripts.TJSON');
return self::$_json->encode($value);
@@ -250,6 +259,9 @@ class TJavaScript
*/
public static function jsonDecode($value)
{
+ if (function_exists('json_decode'))
+ return json_decode($value);
+
if(self::$_json === null)
self::$_json = Prado::createComponent('System.Web.Javascripts.TJSON');
return self::$_json->decode($value);