On Wednesday, 22 February 2017 at 19:26:15 UTC, berni wrote:
In my program, I read a postscript file. Normal postscript
files should only be composed of ascii characters, but one
never knows what users give us. Therefore I'd like to make sure
that the string the program read is only made up of ascii
characters. This simplifies the code thereafter, because I then
can assume, that codeunit==codepoint. Is there a simple way to
do so?
Here a sketch of my function:
void foo(string postscript)
{
// throw Exception, if postscript is not all ascii
// other stuff, assuming codeunit=codepoint
}
void foo(string postscript)
{
import std.ascii, astd.algorithm.ieration;
if (!args[0].filter!(a => !isASCII(a)).empty)
throw new Exception("bla");
}