From 9a80e48394b6a57cda838ea52fc2e8ebb7591a49 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Tue, 20 Jul 2010 21:17:22 +0000 Subject: [PATCH] Slightly different, but similar to brion's tests. I wrote this before I discovered brion's tests. Maybe they'll be useful to someone some day. --- includes/normal/UtfNormalTest2.php | 223 +++++++++++++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 includes/normal/UtfNormalTest2.php diff --git a/includes/normal/UtfNormalTest2.php b/includes/normal/UtfNormalTest2.php new file mode 100644 index 0000000000..7c96006d9a --- /dev/null +++ b/includes/normal/UtfNormalTest2.php @@ -0,0 +1,223 @@ +#!/usr/bin/php +> 6) . chr(0x80 | $c & 0x3F); + } else if ($c <= 0xFFFF) { + return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F) + . chr(0x80 | $c & 0x3F); + } else if ($c <= 0x10FFFF) { + return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) + . chr(0x80 | $c >> 6 & 0x3F) + . chr(0x80 | $c & 0x3F); + } else { + return false; + } +} + +function unistr($c) { + return implode("", array_map("unichr", array_map("hexdec", explode(" ", $c)))); +} + +function getRow( $f ) { + global $comment, $sep; + + $row = fgets( $f ); + if( $row === false ) return false; + $row = rtrim($row); + $pos = strpos( $row, $comment ); + $pos2 = strpos( $row, ")" ); + if( $pos === 0 ) return array($row); + $c = ""; + + if( $pos ) { + if($pos2) $c = substr( $row, $pos2 + 2 ); + else $c = substr( $row, $pos ); + $row = substr( $row, 0, $pos ); + } + + $ret = array(); + foreach(explode( $sep, $row ) as $ent) { + if(trim($ent) !== "") { + $ret[] = unistr($ent); + } + } + $ret[] = $c; + + return $ret; +} \ No newline at end of file -- 2.20.1