2

I have a problem converting the UTF-8 chars to the plain text. Some of them work while some give : ?

echo iconv('UTF-8', 'ASCII//TRANSLIT', "Žluťoøučký kůň")

Outputs:

Zluto?ucky kun

The ø is ?. My Php file is UTF-8 and there is no problem with encoding.

Any Ideas why?

Trying to run in Apache. Works fine when using through terminal php compiling

tika
  • 7,135
  • 3
  • 51
  • 82
  • I am not very sure but do you not have to try setting locale? Also, adding `PHP_EOL` at the end? – user3581203 Apr 14 '15 at 19:51
  • Tried that. If that works in your case, mind posting an answer? – tika Apr 14 '15 at 19:52
  • How are you running this script? From a browser? If I run `php -r "echo iconv('UTF-8', 'ASCII//TRANSLIT', 'Žluťoøučký kůň');"` in my command line, I get the output `Zlutooeucky kun`. – xathien Apr 14 '15 at 20:20
  • @xathien on a `.php` file – tika Apr 14 '15 at 21:12
  • Specifically, are you executing from the command line (somewhat like I did), or are you running it through a Webserver, e.g. Apache? – xathien Apr 14 '15 at 22:43
  • @xathien. Apache (Tried both on Mac an Linux). But, should that make a difference? **I got "o" using php commands, but I need this on a website. Is this some part of apache configuration?** – tika Apr 14 '15 at 23:06
  • Check the request headers that are returning from Apache. Odds are, either Apache is trying to return it in ISO format, or your browser is displaying it wrong. Check [here](http://stackoverflow.com/questions/1605760/how-to-best-configure-php-to-handle-a-utf-8-website) to see if it helps. – xathien Apr 15 '15 at 00:33

0 Answers0