Hey Chris and Harry! I just got the mail below, on optimizing the utf8_check() function. Sounds reasonable to me. Any objections? Andi Begin forwarded message: Date: Thu, 5 Oct 2006 11:20:19 +0300 (EEST) From: Joel Yliluoma <joel.yliluoma@xxxxxx> To: Andreas Gohr <andi@xxxxxxxxxxxxxx> Subject: Re: phpfreechat utf8.php optimization ideas On Thu, 5 Oct 2006, Joel Yliluoma wrote: > The function utf8_check() could be written as: And after correcting for typoes, it becomes: > function utf8_check($Str) > { > $b1 = "[\000-\177]"; > $b2 = "[\301-\337][\200\277]"; > $b3 = "[\341-\357][\200\277][\200\277]"; > $b4 = "[\361-\367][\200\277][\200\277][\200\277]"; > $b5 = "[\371-\375][\200\277][\200\277][\200\277][\200\277]"; > return ereg("^($b1|$b2|$b3|$b4|$b5)*\$", $Str); > } -- Joel Yliluoma http://iki.fi/bisqwit/ -- http://www.splitbrain.org