Reputation: 872
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!
Upvotes: 4
Views: 1010
Reputation: 1470
I had the same problem. I found that locale was changing by /etc/apache2/envvars
Upvotes: 1
Reputation: 872
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?
Upvotes: 1