2

I'm like 1 day new to Zend and i ran into my first problem.
It seems i can't find anything in google or documentation about string transliteration.

For example Kohana has UTF8::transliterate_to_ascii

I need to turn all sort of characters (ę, ų ...) to english looking ones.

How you do that in Zend?

arma
  • 4,084
  • 10
  • 48
  • 63
  • Take a look at http://www.http://php.net/manual/en/function.utf8-decode.php – vascowhite Dec 20 '11 at 03:30
  • 1
    Use iconv http://stackoverflow.com/questions/158241/php-replace-umlauts-with-closest-7-bit-ascii-equivalent-in-an-utf-8-string instead – akond Dec 20 '11 at 07:03
  • @akond for iconv to work i need to change locale with setlocale(), how that possibly would impact on other code in zend? – arma Dec 20 '11 at 10:19
  • 1
    You could save current locale, apply a new one, and after the iconv () is done, resort to the original one. – akond Dec 20 '11 at 15:25

1 Answers1

0

Based on link provided by akond i resolved my issue:

First get current locale and store it:
$orginial_locale = setlocale(LC_CTYPE, 0);

After set locale to one you desire:
setlocale(LC_CTYPE, 'en_US.UTF-8');

Then apply iconv to string:
iconv("utf-8", "ascii//TRANSLIT", $input);

And finaly restore back to original locale:
setlocale(LC_CTYPE, $orginial_locale);

You should adjust setlocale category based on your needs see setlocale documentation for information on categories.

Community
  • 1
  • 1
arma
  • 4,084
  • 10
  • 48
  • 63