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

Meta jared771 at gmail.com
Thu Jul 25 22:54:42 PDT 2013


On Friday, 26 July 2013 at 05:06:45 UTC, Jonathan M Davis wrote:
> Unicode contains ASCII, but very few Unicode characters are 
> ASCII, because
> there just aren't very many ASCII characters and there and a 
> _ton_ of Unicode
> characters. The std.ascii functions return true for certain 
> sets of ASCII
> characters and false for everything else. The std.uni functions 
> return true
> for many Unicode characters as well. You wouldn't normally use 
> std.ascii if
> you're operating on non-ASCII Unicode characters, but it 
> ignores them if it
> does run into them.
>
> std.ascii.isWhite only cares about ASCII whitespace, which the 
> documentation
> explicitly lists as the space, tab, vertical tab, form feed, 
> carriage return,
> and linefeed characters. Those characters will return true. All 
> other
> characters will return false.
>
> std.uni.isWhite returns true for all of the characters that 
> std.ascii.isWhite
> does plus a whole bunch of other non-ASCII characters that the 
> Unicode
> standard considers to be whitespace.
>
> Which function you use depends on what you're trying to do.
>
> - Jonathan M Davis

That makes sense. I know that the first 127 unicode characters 
are equivalent to the 7-bit ASCII charset, but it confused me 
that the module is named std.ascii when it actually operates on 
unicode characters, I guess.

Another question, I'm not all that familiar with unicode, so what 
is the difference between std.uni.isNumber and 
std.ascii.isNumber? Am I right in thinking that std.uni.isNumber 
will match things outside of the basic 0..9?


More information about the Digitalmars-d-learn mailing list