note 104040 deleted from function.iconv by danbrown

From: Date: Thu, 19 May 2011 13:52:53 +0000
Subject: note 104040 deleted from function.iconv by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-179880@lists.php.net to get a copy of this message
Note Submitter: Bryce ---- Pulling together into one test script all the above examples and calling syntax: <?php $string = "Šíleně žluťoučký Vašek úpěl olol! — ﺎﻠﻋﺮﺒﻳﺓ"; //setlocale(LC_ALL, 'en_US.UTF8'); print "Input:\n$string\n\n"; print "ASCII//TRANSLIT:\n" .iconv('UTF-8', 'ASCII//TRANSLIT', $string)."\n\n"; print "ASCII//IGNORE:\n" .iconv('UTF-8', 'ASCII//IGNORE', $string)."\n\n"; print "ASCII//IGNORE//TRANSLIT:\n".iconv('UTF-8', 'ASCII//IGNORE//TRANSLIT', $string)."\n\n"; print "ASCII//TRANSLIT//IGNORE:\n".iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $string)."\n\n"; print "clearUTF:\n" .clearUTF($string)."\n"; // http://us.php.net/manual/en/function.iconv.php#93609 function clearUTF($s) { $r = ''; $s1 = iconv('UTF-8', 'ASCII//TRANSLIT', $s); for ($i = 0; $i < strlen($s1); $i++) { $ch1 = $s1[$i]; $ch2 = mb_substr($s, $i, 1); $r .= $ch1=='?'?$ch2:$ch1; } return $r; } ?> Your mileage may vary. On my Ubuntu Linux system none of the above produce the desired output: Silene zlutoucky Vasek upel olol! -- ﺎﻠﻋﺮﺒﻳﺓ

« previous php.notes (#179880) next »