summaryrefslogtreecommitdiff
path: root/includes/inc_utils.php
diff options
context:
space:
mode:
authorTheTroll <trolldev@gmail.com>2010-02-25 14:17:28 +0100
committerTheTroll <trolldev@gmail.com>2010-02-25 14:17:28 +0100
commitca4074913b2ad21eac4987df1349fc386fc9b9a7 (patch)
treedaf9d1093344d228e68ceb4b3708d844fd0383da /includes/inc_utils.php
parent0523957900c8962c67aa466236b579d1e870a5fb (diff)
downloadistreamdev-ca4074913b2ad21eac4987df1349fc386fc9b9a7.tar.gz
istreamdev-ca4074913b2ad21eac4987df1349fc386fc9b9a7.tar.bz2
Changed converted strings format
Diffstat (limited to 'includes/inc_utils.php')
-rwxr-xr-xincludes/inc_utils.php97
1 files changed, 53 insertions, 44 deletions
diff --git a/includes/inc_utils.php b/includes/inc_utils.php
index 541c35b..071d8b0 100755
--- a/includes/inc_utils.php
+++ b/includes/inc_utils.php
@@ -1,50 +1,59 @@
<?php
-function is_utf8($str) {
- $c=0; $b=0;
- $bits=0;
- $len=strlen($str);
- for($i=0; $i<$len; $i++){
- $c=ord($str[$i]);
- if($c > 128){
- if(($c >= 254)) return false;
- elseif($c >= 252) $bits=6;
- elseif($c >= 248) $bits=5;
- elseif($c >= 240) $bits=4;
- elseif($c >= 224) $bits=3;
- elseif($c >= 192) $bits=2;
- else return false;
- if(($i+$bits) > $len) return false;
- while($bits > 1){
- $i++;
- $b=ord($str[$i]);
- if($b < 128 || $b > 191) return false;
- $bits--;
- }
- }
- }
- return true;
+function is_utf8($str)
+{
+ $c=0; $b=0;
+ $bits=0;
+ $len=strlen($str);
+ for($i=0; $i<$len; $i++)
+ {
+ $c=ord($str[$i]);
+ if($c > 128)
+ {
+ if(($c >= 254)) return false;
+ elseif($c >= 252) $bits=6;
+ elseif($c >= 248) $bits=5;
+ elseif($c >= 240) $bits=4;
+ elseif($c >= 224) $bits=3;
+ elseif($c >= 192) $bits=2;
+ else return false;
+ if(($i+$bits) > $len) return false;
+ while($bits > 1)
+ {
+ $i++;
+ $b=ord($str[$i]);
+ if($b < 128 || $b > 191) return false;
+ $bits--;
+ }
+ }
+ }
+ return true;
}
-function php2js ($var) {
- if (is_array($var)) {
- $res = "[";
- $array = array();
- foreach ($var as $a_var) {
- $array[] = php2js($a_var);
- }
- return join(",", $array);
- }
- elseif (is_bool($var)) {
- return $var ? "true" : "false";
- }
- elseif (is_int($var) || is_integer($var) || is_double($var) || is_float($var)) {
- return $var;
- }
- elseif (is_string($var)) {
- return "\"" . addslashes(stripslashes($var)) . "\"";
- }
- // autres cas: objets, on ne les gère pas
- return FALSE;
+function php2js ($var)
+{
+ if (is_array($var))
+ {
+ $array = array();
+
+ foreach ($var as $a_var)
+ $array[] = php2js($a_var);
+
+ return str_replace("\"", "'", join(",", $array));
+
+
+ }
+
+ elseif (is_bool($var))
+ return ($var ? "true" : "false");
+
+ elseif (is_int($var) || is_integer($var) || is_double($var) || is_float($var))
+ return $var;
+
+ elseif (is_string($var))
+ return "\"" . addslashes(stripslashes($var)) . "\"";
+
+ else
+ return false;
}