private function _toUTF8($str)
    {
        $str = trim(preg_replace('/[\x00-\x09\x0b-\x1F]/', ' ', $str)); //remove nonprintable characters
        if ($this->_encoding != null) {
            if (strcasecmp($this->_encoding, "UTF-8") == 0) {
                return $str;
            } elseif (strcasecmp($this->_encoding, "CP437") == 0) {
                $strr = "";
                if (($strl = strlen($str)) > 0) for ($i = 0; $i < $strl; $i++) {
                    $strc = substr($str, $i, 1);
                    if ($strc < 128) $strr.=$strc;
                        else $strr.=self::$_CP437toUTF8Table[$strc-128];
                }

                 return $strr;
            } else {
                if (preg_match("/^windows-\d+ \((.+)\)$/", $this->_encoding, $buf)) {
                    $encoding = $buf[1];
                } else {
                    $encoding = $this->_encoding;
                }
                $enclist = mb_list_encodings();
                if (in_array($encoding, $enclist)) {
                    return mb_convert_encoding($str, 'UTF-8', $encoding);
                } elseif (function_exists("iconv")) {
                    if (($iconvout=iconv($encoding, 'UTF-8', $str))!==false) {
                        return $iconvout;
                    } else {
                        return mb_convert_encoding($str, 'UTF-8');
                    }
                } elseif (function_exists("libiconv") && (($iconvout=libiconv($encoding, 'UTF-8', $str))!==false)) {
                    return $iconvout;
                } else {
                    return mb_convert_encoding($str, 'UTF-8');
                }
           }
        } else {
            return mb_convert_encoding($str, 'UTF-8');
        }
    }