I'm working on a function to Anglicise a string. Here's part of it in a testing assembly:
(apologies for it not being in code tags, but it was converting the characters and making it less readable)
<html>
<head>
<title> splurd </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<?php
function oooo($string) {
$string = /*@*/preg_replace('/[ÒÓÔÕÖØŌŎŐƟƠǑǪǬǾȌȎȪȬȮȰᴏᴼṌṎṐṒỌỎỒỔỖỘỚỜỞỠỢ]/u', 'O', $string) or print "pungo"; // nothing prints here
}
$ooooo = "$_POST[input]";
$ooooo = oooo($ooooo);
echo "<h1>$ooooo</h1>"; // nothing inside the header tags
echo ord($ooooo); // 0
var_dump($ooooo); // NULL
echo str_replace("Ố", "O", "ỐỐ"); // prints "OO"
$text="עברית מבולגנת";
function hebrewNotWordEndSwitch ($from, $to, $text) {
$text=
preg_replace('/'.$from.'([א-ת])/u','$2'.$to.'$1',$text);
return $text;
}
do {
$text_before=$text;
$text=hebrewNotWordEndSwitch("ך","כ",$text);
$text=hebrewNotWordEndSwitch("ם","מ",$text);
$text=hebrewNotWordEndSwitch("ן","נ",$text);
$text=hebrewNotWordEndSwitch("ף","פ",$text);
$text=hebrewNotWordEndSwitch("ץ","צ",$text);
} while ( $text_before!=$text );
print $text; // עברית מסודרת!
?>
</body>
</html>
I also got a function from http://au2.php.net/manual/en/function.preg-replace.php to test if it was indeed working (the Hebrew one), and it works.
So I send the following string to it: ÒÓÔÕÖ . It returns null. I know that if the pattern is malformed utf-8 the function returns null, but I can't see what's wrong with it.
Any help would be very much appreciated.
Thanks.
EDIT: I'm on FreeBSD 6.1 using PHP 5.2.5 (updated yesterday).