REPLACE_INVALID_UTF8 patch