Substitutes invalid UTF-8 sequences to ensure control characters and malformed data are properly handled.
Closes #3549107