Rename std.ctype to std.ascii?

Timon Gehr timon.gehr at gmx.ch
Tue Jun 14 12:29:28 PDT 2011


Daniel Gibson wrote:
> Am 14.06.2011 20:58, schrieb Andrej Mitrovic:
>> Why does std.ctype exist anyway? Can't you use std.uni for both ASCII
>> and UTF? Or is there some overhead in using the uni functions?
>
> I haven't looked at either implementation, but on ASCII everything is
> really simple.. isalpha, isdigit, isupper and islower are just a simple
> checks if the value is between two values, tolower(dchar c) is just
> return isupper(c) ? c+32 : c; etc.
> For Unicode this is most probably *much* harder (=> more expensive).
>
> Cheers,
> - Daniel

The implementation of toUniLower shortcuts on ASCII characters. I don't expect it
to be any slower if not for inlineability. And if somebody really needs the speed,
I feel manually writing if('A' <= c && c <= 'Z') c+=32; (or similar) is just good
enough.


Timon


More information about the Digitalmars-d mailing list