note 105507 added to function.iconv

From: Date: Tue, 23 Aug 2011 15:22:20 +0000
Subject: note 105507 added to function.iconv
Groups: php.notes 
Request: Send a blank email to php-notes+get-182676@lists.php.net to get a copy of this message
Interestingly, setting different target locales results in different, yet appropriate, transliterations. For example: <?php //some German $utf8_sentence = 'Weiß, Goldmann, Göbel, Weiss, Göthe, Goethe und Götz'; //UK setlocale(LC_ALL, 'en_GB'); //transliterate $trans_sentence = iconv('UTF-8', 'ASCII//TRANSLIT', $utf8_sentence); //gives [Weiss, Goldmann, Gobel, Weiss, Gothe, Goethe und Gotz] //which is our original string flattened into 7-bit ASCII as //an English speaker would do it (ie. simply remove the umlauts) echo $trans_sentence . PHP_EOL; //Germany setlocale(LC_ALL, 'de_DE'); $trans_sentence = iconv('UTF-8', 'ASCII//TRANSLIT', $utf8_sentence); //gives [Weiss, Goldmann, Goebel, Weiss, Goethe, Goethe und Goetz] //which is exactly how a German would transliterate those //umlauted characters if forced to use 7-bit ASCII! //(because really ä = ae, ö = oe and ü = ue) echo $trans_sentence . PHP_EOL; ?> ---- Server IP: 109.169.40.147 Probable Submitter: 109.148.34.92 ---- Manual Page -- http://www.php.net/manual/en/function.iconv.php Edit -- https://master.php.net/note/edit/105507 Del: integrated -- https://master.php.net/note/delete/105507/integrated Del: useless -- https://master.php.net/note/delete/105507/useless Del: bad code -- https://master.php.net/note/delete/105507/bad+code Del: spam -- https://master.php.net/note/delete/105507/spam Del: non-english -- https://master.php.net/note/delete/105507/non-english Del: in docs -- https://master.php.net/note/delete/105507/in+docs Del: other reasons-- https://master.php.net/note/delete/105507 Reject -- https://master.php.net/note/reject/105507 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182676) next »