diff --git a/inc/utf8.php b/inc/utf8.php
index 661e84bd88459f2c0582aa0549700d406d817c4d..a438783f7524f91fbd65e00b025e90e04ad56e18 100644
--- a/inc/utf8.php
+++ b/inc/utf8.php
@@ -78,13 +78,14 @@ if(!function_exists('utf8_strip')){
      * @author Andreas Gohr <andi@splitbrain.org>
      */
     function utf8_strip($str){
-      $ascii = '';
-      for($i=0; $i<strlen($str); $i++){
-        if(ord($str{$i}) <128){
-          $ascii .= $str{$i};
+        $ascii = '';
+        $len = strlen($str);
+        for($i=0; $i<$len; $i++){
+            if(ord($str{$i}) <128){
+                $ascii .= $str{$i};
+            }
         }
-      }
-      return $ascii;
+        return $ascii;
     }
 }
 
@@ -96,7 +97,8 @@ if(!function_exists('utf8_check')){
      * @link   http://www.php.net/manual/en/function.utf8-encode.php
      */
     function utf8_check($Str) {
-        for ($i=0; $i<strlen($Str); $i++) {
+        $len = strlen($Str);
+        for ($i=0; $i<$len; $i++) {
             $b = ord($Str[$i]);
             if ($b < 0x80) continue; # 0bbbbbbb
             elseif (($b & 0xE0) == 0xC0) $n=1; # 110bbbbb
@@ -107,7 +109,7 @@ if(!function_exists('utf8_check')){
             else return false; # Does not match any model
 
             for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
-                if ((++$i == strlen($Str)) || ((ord($Str[$i]) & 0xC0) != 0x80))
+                if ((++$i == $len) || ((ord($Str[$i]) & 0xC0) != 0x80))
                     return false;
             }
         }