A Philosophy of Software Design
Jon Degenhardt
jondegenhardt at nowhere.com
Tue Jun 30 06:31:14 UTC 2026
On Monday, 29 June 2026 at 07:55:14 UTC, Walter Bright wrote:
> On 6/28/2026 10:16 PM, Jon Degenhardt wrote:
>> Unicode error handling is worth attention because of all the
>> trouble it's been for D.
>
> The trouble it's been for D is the autodecoding done in Phobos,
> which throws exceptions when it cannot autodecode.
>
> The best approach is to simply replace the bad code units with
> the invalid code point. If any of the other methods you
> mentioned are desired, that can be implemented by creating a
> filter which looks for an invalid code point, and then throws
> or deletes it or whatever the filter is programmed to do.
Autodecoding was a mistake and should be removed in a versioned
Phobos library.
If only one strategy is going to be supported by library code,
the best choice is pass-through, not replacement. That way the
application layer can do post filtering and handle the error
itself. Replacement is information lossy and cannot be undone or
compensated for at the application level. Note that it is common
for applications that act as intermediate text processing steps
are required to support pass-through behavior.
--Jon
More information about the Digitalmars-d
mailing list