summaryrefslogtreecommitdiff
path: root/includes/inc_utils.php
diff options
context:
space:
mode:
authorAlib <aliboba@free.fr>2010-02-19 15:44:49 +0100
committerAlib <aliboba@free.fr>2010-02-19 15:44:49 +0100
commit2441137a2fbb63547d1963da57c894e8ef889a80 (patch)
treec47d197546a6fcf35bc0edce83abe60a183bcd8e /includes/inc_utils.php
parent1c07c44adc4af0495c2535904f5f863d36041d62 (diff)
parent97119d9248475946e69ed8485fdd4723c5f54fbe (diff)
downloadistreamdev-2441137a2fbb63547d1963da57c894e8ef889a80.tar.gz
istreamdev-2441137a2fbb63547d1963da57c894e8ef889a80.tar.bz2
Merge branch 'master' of projects.vdr-developer.org:istreamdev
Diffstat (limited to 'includes/inc_utils.php')
-rw-r--r--includes/inc_utils.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/includes/inc_utils.php b/includes/inc_utils.php
new file mode 100644
index 0000000..a984794
--- /dev/null
+++ b/includes/inc_utils.php
@@ -0,0 +1,27 @@
+<?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;
+}
+?>