On Friday, 26 July 2013 at 04:09:46 UTC, Meta wrote:
I'm confused about which isWhite function I should use. Aren't
all chars in D (char, wchar, dchar) unicode characters?
They are.
Should I always use std.uni.isWhite, unless I'm working with
bytes and byte arrays?
No, char vs byte isn't necessarily a thing here.
The documentation doesn't give me much to go on, beside "All of
the functions in std.ascii accept unicode characters but
effectively ignore them. All isX functions return false for
unicode characters, and all toX functions do nothing to unicode
characters."
You should use std.uni.isWhite unless you want to match only
ASCII white space.
That could be the case when ...
* You have data that is not in Unicode, but some other superset
of ASCII. Then you shouldn't use std.uni.isWhite, of course.
std.ascii.isWhite might be fine. In this case, you'd actually use
u{byte,short,int} instead of {,w,d}char.
* You're dealing with a grammar where ASCII white space is a
thing, while Unicode white space is not.
* There's really only ASCII white space in your data, and you
want every bit of speed, and you've verified that
std.ascii.isWhite is indeed faster than std.uni.isWhite.