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!
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?
I had the same problem. I found that locale was changing by /etc/apache2/envvars
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.