Domanda

I am trying to use iconv to remove accents from names using this function

$name = iconv('UTF-8', 'ASCII//TRANSLIT', $original)

So if $original was 'šñć' I would expect 'snc'.

Running this via a PHP script in the command line does produce the expected result, however running the same function in a Symfony 2 application in an Apache web server (on the same machine) removes all accented characters from the output string - so that 'Bijelić' becomes 'Bijeli'

What factors could be a effect this and how could I get the result I want calling this function in Symfony? Thanks!

È stato utile?

Soluzione

I had the same problem. I found that locale was changing by /etc/apache2/envvars

Altri suggerimenti

So it does turn out that the Locale was not set the same for Apache and the CLI.

Calling setlocale(LC_CTYPE, "en_US.utf8"); before calling iconv produces the expected result.

How does one set the LC_CTYPE in either PHP or Apache?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top