Provide a condition in string-based IO routines

Part of Issue #4837 

Rust's string-based IO routines should provide a condition for hooking in different behavior when presented with malformed UTF-8.