[Issue 11356] isASCII for strings

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jun 13 10:27:52 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=11356

--- Comment #2 from monarchdodra at gmail.com ---
(In reply to Andrej Mitrovic from comment #1)
> https://github.com/D-Programming-Language/phobos/pull/1665
> 
> I don't know why Walter was so hanged up about this. It's a simple function.
> I think it's worth reopening and maybe casting a vote in the forums.

I've been meaning to reply to this for a while, but you know how it is...

Anywhoo, one of the issues that stopped me from re-opening it, was defining a
useful interface: Returning "simply" a bool is fine and all, but chances are
that when the function returns "false", as user wants to know "Ok, there's
non-ASCII characters in here. Where are they?". So without making the function
more complicated, there are chances it could return more information than
"just" yes/no.

I'd have suggested that isASCII return a slice that starts at (or roughly
before) the first non-ASCII character in the string. This would be useful for
input with "little to no unicode". The *issue* with this is that is would
"flip" isASCII's return code, "thanks" to implicit slice to bool conversion >:(

Or maybe I'm just over-engineering. What's for sure, I don't want to introduce
more than 1 function for this...

--


More information about the Digitalmars-d-bugs mailing list