php - Why doesn't translit work? -
setlocale(lc_all, 'en_us.utf8'); $string= 'ṃỹṛèşưḿĕ'; echo iconv('utf-8', 'ascii//translit', $string);
makes error...
should print: myresume
it depends on iconv library.
in ubuntu 10.10, this:
$ php -i | egrep "iconv (implementation|library)" iconv implementation => glibc iconv library version => 2.12.1 $ php a.php myresume
but on machine using gnu iconv:
iconv implementation => libiconv iconv library version => 1.11 # php a.php notice: iconv(): unknown error (88) in /tmp/root/a.php on line 5
the transliteration done iconv not consistent across implementations. instance, glibc implementation transliterates é
e
, libiconv transliterates 'e
.
until have support icu transliterators in php (due next version), there won't realiable way reliable these transformation (though if want remove marks, there other solutions). in development version of php, intl extension, it's possible this:
<?php $t = transliterator::create("latin; nfkd; [^\u0000-\u007e] remove; nfc"); echo $t->transliterate('Ναδάλης ṃỹṛèşưḿĕ');
which gives
nadales myresume
Comments
Post a Comment