I also got this error. I use lib version 1.5.
I to debug your code and found an inaccuracy in one regular expression.
You have inaccuracy in the method "parse_charset" in this row (1231)
$success = preg_match('/charset=(.+)/', $fullvalue, $matches);
Add to your pattern modifier "i", because if the text has html tags in a different register, the encoding is not determined correctly.