Improve documentNotUTF8 check in ToolsError for HTML support