About std.ascii.toLower

Jonathan M Davis jmdavisProg at gmx.com
Thu Sep 20 09:57:53 PDT 2012


On Thursday, September 20, 2012 18:35:21 bearophile wrote:
> monarch_dodra:
> > It's not, it only *operates* on ASCII, but non ascii is still a
> 
> > legal arg:
> Then maybe std.ascii.toLower needs a pre-condition that
> constraints it to just ASCII inputs, so it's free to return a
> char.

Goodness no.

1. Operating on a char is almost always the wrong thing to do. If you really 
want to do that, then cast. It should _not_ be encouraged.

2. It would be disastrous if std.ascii's funtions didn't work on unicode. 
Right now, you can use them with ranges on strings which are unicode, which 
can be very useful. I grant you that that's more obvious with something like 
isDigit than toLower, but regardless, std.ascii is designed such that its 
functions will all operate on unicode strings. It just doesn't alter unicode 
characters and returns false for them with any of the query functions.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list