in reply to UTF-8 warnings
The problem is that $text is internally invalid because something told Perl a buffer contained UTF-8 when it didn't.