|Title:||Autodecode Should Not Throw|
|Author:||Andrei Alexandrescu and Walter Bright|
|Links:||NG Discussion — RFE|
When the autodecoder encounters invalid UTF, it throws an exception. This proposal changes that so it replaces the invalid UTF with the Replacement Character.
- Becomes nothrow, which enables code that uses it to become nothrow. Nothrow code does not need to produce exception unwinding wrappers, which can improve the performance of using ref counted objects.
- Becomes @nogc, because the thrown exception is allocated on the GC.
- Becomes consistent with the behavior of std.utf.byDchar().
- Will be somewhat faster.
- Current industry practice has evolved towards using replacement characters for bad UTF rather than failing.
Breaking Existing Code
This can break existing code, although it seems highly unlikely that any programs actually require the decoding to throw on invalid UTF.
There doesn't seem to be any deprecation path for this change. It will have to be abrupt.
This document has been placed in the Public Domain.