preg_match('#charset="?(.*)"#si', $meta[0], $encoding);
# if charset is found set it otherwise, set it to utf-8
$html_charset = (!empty($encoding[1])) ? strtolower($encoding[1]) : 'utf-8';
+ if (empty($encoding[1])) $encoding[1] = 'utf-8';
} else {
$html_charset = 'utf-8';
$encoding[1] = '';