bearophile

monarch_dodra monarchdodra at gmail.com
Thu Sep 20 09:18:35 PDT 2012


On Thursday, 20 September 2012 at 16:00:18 UTC, bearophile wrote:
> This is the signature of a function of std.ascii:
>
> http://dlang.org/phobos/std_ascii.html#toLower
>
> pure nothrow @safe dchar toLower(dchar c);
>
> If this function is supposed to be used on ASCII strings, 
> what's the point of returning a dchar? When I use it I have 
> usually to cast its result back to char, and I prefer to avoid 
> casts in my code in D.
>
> Bye,
> bearophile

It's not, it only *operates* on ASCII, but non ascii is still a 
legal arg:

----
import std.stdio;
import std.ascii;

void main(){
     string s = "héllö";
     write("\"");
     foreach(c; s)
         write(c.toUpper);
     write("\"");
}
----
HéLLö
----


More information about the Digitalmars-d-learn mailing list