I saw there are different discussion on this subject and I did find some solutions, but I still can't fix the accent problem.
I have a text in Italian, we have some letters with accents ( à
, è
, é
, ì
, ò
and ù
), this text gets sent in a file over to another website and this has to be in ASCII
format, this is what I'm currently doing:
$res_to_write = "Non c'è più l'oblò, è lì o là?" //DEMO TEXT
$resfile = iconv("UTF-8", "US-ASCII//TRANSLIT", $res_to_write);
The result is in ASCII, which is good but it gets converted to:
Non c'e piu l'oblo, e li o la?
Which is completely wrong in Italian.
Do I have to make a replace of every accent like è
=> e'
(single quote) so at least looks ok or there is another solution to this?
As of now I don't have other solutions other than replace it with an apostrophe:
$res_to_write = "Non c'è più l'oblò, è lì o là?" //DEMO TEXT
$res_to_write = str_replace(['à', "è", "é", "ì", "ò", "ù"], ["a'", "e'", "e'", "i", "o'", "u'"], $res_to_write);
$resfile = iconv("UTF-8", "US-ASCII//TRANSLIT", $res_to_write);
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.