Checking, whether string contains only ascii.

berni via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 22 11:26:15 PST 2017


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


More information about the Digitalmars-d-learn mailing list