note 104040 added to function.iconv

From: Date: Thu, 19 May 2011 03:51:21 +0000
Subject: note 104040 added to function.iconv
Groups: php.notes 
Request: Send a blank email to php-notes+get-179867@lists.php.net to get a copy of this message
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! -- ﺎﻠﻋﺮﺒﻳﺓ ---- Server IP: 208.69.120.55 Probable Submitter: 24.7.86.43 ---- Manual Page -- http://www.php.net/manual/en/function.iconv.php Edit -- https://master.php.net/note/edit/104040 Del: integrated -- https://master.php.net/note/delete/104040/integrated Del: useless -- https://master.php.net/note/delete/104040/useless Del: bad code -- https://master.php.net/note/delete/104040/bad+code Del: spam -- https://master.php.net/note/delete/104040/spam Del: non-english -- https://master.php.net/note/delete/104040/non-english Del: in docs -- https://master.php.net/note/delete/104040/in+docs Del: other reasons-- https://master.php.net/note/delete/104040 Reject -- https://master.php.net/note/reject/104040 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179867) next »