Re: test for ascii or binary string

From: Date: Sat, 30 Nov 2002 13:36:30 +0000
Subject: Re: test for ascii or binary string
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-126532@lists.php.net to get a copy of this message
At 13:38 30.11.2002, Beth Gore said: --------------------[snip]-------------------- Add a "break" statement once you've detected binary, for optimization (binary might be just some length...) <?php >function isbinary($input) { /* This simple function returns true if there's any non-standard Ascii characters */ $isbinary = 0; for($x=0;$x < strlen($input); $x++) { $c = substr($input,$x,1); if($c < chr(32) or $c > chr(127)) { /* add expected european extended characters */ if($c != chr(10) or $c != chr(13) or $c != chr(9)) { $isbinary = 1; /* >>> */ break; } } } return $isbinary; } -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#126532) next »