diff options
Diffstat (limited to 'framework')
-rw-r--r-- | framework/Web/Javascripts/TJavaScript.php | 12 |
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);
|