From 97119d9248475946e69ed8485fdd4723c5f54fbe Mon Sep 17 00:00:00 2001 From: TheTroll Date: Fri, 19 Feb 2010 15:41:05 +0100 Subject: Convert channels EPG/title to UTF8 is needed --- includes/inc_utils.php | 27 +++++++++++++++++++++++++++ includes/inc_vdr.php | 7 +++++++ includes/include.php | 1 + 3 files changed, 35 insertions(+) create mode 100644 includes/inc_utils.php (limited to 'includes') 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 @@ + 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; +} +?> diff --git a/includes/inc_vdr.php b/includes/inc_vdr.php index 07880e7..c96217c 100755 --- a/includes/inc_vdr.php +++ b/includes/inc_vdr.php @@ -83,6 +83,13 @@ function vdrgetinfostream($stream = "NULL", $ischan = 1) $epgdesc=substr($allepg[$i], 2); } } + + // Convert if needed + if (!is_utf8($epgtitle)) + $epgtitle = utf8_encode($epgtitle); + if (!is_utf8($epgdesc)) + $epgdesc = utf8_encode($epgdesc); + return array($epgtitle, $epgdesc, $channame); } diff --git a/includes/include.php b/includes/include.php index 830b4b1..913b22a 100755 --- a/includes/include.php +++ b/includes/include.php @@ -4,6 +4,7 @@ if (file_exists('config.php')) include ('config.php'); else include ('config_default.php'); +include ('includes/inc_utils.php'); include ('includes/inc_auth.php'); include ('includes/inc_vdr.php'); include ('includes/inc_files.php'); -- cgit v1.2.3