[dokuwiki] Fw: utf8.php utf8_check optimization idea

  • From: Andreas Gohr <andi@xxxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Fri, 6 Oct 2006 16:47:22 +0200

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

Other related posts: