Closed jjn555 closed 3 years ago
I don't quite understand how this would look - but I'm not against the idea in principle. Would be happy to accept a PR for this!
This would be similar to what is implemented as utf8::replace_invalid() in this open source utf8 library: https://github.com/nemtrif/utfcpp
A common use case is that an application has to somehow work with the string provided even if it may have invalid sequences. This function would replace invalid utf8 sequences in a string with the specified valid utf8 character byte, ensuring that the output is valid utf8 and has the same total byte length as the input.