DIP76: Autodecode Should Not Throw

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 19 01:19:06 PDT 2015


On Monday, April 06, 2015 20:16:19 Walter Bright via Digitalmars-d wrote:
> http://wiki.dlang.org/DIP76

I am fully in favor of this. Most code really doesn't care about invalid
unicode, and if it does, it can check explicitly. Using the replacement
character is much cleaner and follows the Unicode standard.

And in my experience, if I run into invalid Unicode, I generally have to
process it regardless, forcing me to do something like use the replacement
character anyway. The fact that std.utf.decode throws just becomes an
annoyance.

About the only real downside to this that I can think of is that if you're
writing a new string algorithm, and you botch it such that it mangles the
Unicode, right now, you'd quickly get exceptions, whereas with this change,
you wouldn't. But if you're testing your string-based code with Unicode
rather than just ASCII, then that should still get caught. Regardless, I
think that this is the way to go.

- Jonathan M Davis



More information about the Digitalmars-d mailing list