Index: wp-includes/streams.php
===================================================================
--- wp-includes/streams.php	(revision 8395)
+++ wp-includes/streams.php	(working copy)
@@ -58,9 +58,12 @@
   function StringReader($str='') {
     $this->_str = $str;
     $this->_pos = 0;
+    // If string functions are overloaded, we need to use the mb versions
+    $this->is_overloaded = ((ini_get("mbstring.func_overload") & 2) != 0) && function_exists('mb_substr');
   }
 
   function read($bytes) {
+    if ($this->is_overloaded) return $this->mb_read($bytes);
     $data = substr($this->_str, $this->_pos, $bytes);
     $this->_pos += $bytes;
     if (strlen($this->_str)<$this->_pos)
@@ -68,22 +71,44 @@
 
     return $data;
   }
+  
+  function mb_read($bytes) {
+    $data = mb_substr($this->_str, $this->_pos, $bytes, 'ascii');
+    $this->_pos += $bytes;
+    if (mb_strlen($this->_str, 'ascii')<$this->_pos)
+      $this->_pos = mb_strlen($this->_str, 'ascii');
 
+    return $data;
+  }
+
   function seekto($pos) {
+    if ($this->is_overloaded) return $this->mb_seekto($pos);
     $this->_pos = $pos;
     if (strlen($this->_str)<$this->_pos)
       $this->_pos = strlen($this->_str);
     return $this->_pos;
   }
+  
+  function mb_seekto($pos) {
+    $this->_pos = $pos;
+    if (mb_strlen($this->_str, 'ascii')<$this->_pos)
+      $this->_pos = mb_strlen($this->_str, 'ascii');
+    return $this->_pos;
+  }
 
   function currentpos() {
     return $this->_pos;
   }
-
+  
   function length() {
+    if ($this->is_overloaded) return $this->mb_length();
     return strlen($this->_str);
   }
 
+  function mb_length() {
+    return mb_strlen($this->str, 'ascii');
+  }
+  
 }
 
 
@@ -149,17 +174,18 @@
 // over it (it assumes knowledge of StringReader internals)
 class CachedFileReader extends StringReader {
   function CachedFileReader($filename) {
+    parent::StringReader();
+
     if (file_exists($filename)) {
 
       $length=filesize($filename);
       $fd = fopen($filename,'rb');
 
       if (!$fd) {
-	$this->error = 3; // Cannot read file, probably permissions
-	return false;
+        $this->error = 3; // Cannot read file, probably permissions
+        return false;
       }
       $this->_str = fread($fd, $length);
-	  $this->_pos = 0;
 	  fclose($fd);
 
     } else {

