isAsciiString in Phobos?
Adam D. Ruppe
destructionator at gmail.com
Mon Oct 7 08:22:26 PDT 2013
On Monday, 7 October 2013 at 15:18:06 UTC, Andrej Mitrovic wrote:
> bool isAscii = mystring.all!(a => a <= 0xFF);
If you want strict ASCII, it should be <= 127 rather than 255
because the high bit can be all kinds of different encodings (the
first 255 of unicode codepoints I think match latin-1
numerically, but that's different than windows-1252 or various
non-English extended asciis.)
You could also convert utf-8 to ascii.... sort of... by just
stripping out any byte > 127 since bytes higher than that are
multibyte sequences in utf8.
More information about the Digitalmars-d-learn
mailing list