Should I Use std.ascii.isWhite or std.uni.isWhite?

Meta jared771 at gmail.com
Thu Jul 25 22:56:11 PDT 2013


On Friday, 26 July 2013 at 05:26:33 UTC, anonymous wrote:
>> 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.

I realized after I posted this that I was being stupid in even 
suggesting that, seeing as all the functions in std.ascii take 
dchars.

>> 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.

Thank you for the informative answer.


More information about the Digitalmars-d-learn mailing list