I use iconv()
to convert CSV data from UTF-8 to Windows-1252.
$converted = iconv("UTF-8", "Windows-1252", $csvData);
In some cases, iconv()
failed quietly, returning false
.
I also tried using //TRANSLIT
but `iconv()´ returns false here as well.
When i add the //IGNORE
statement to the target charset, the conversion succeeds, but that means one or more character(s) got lost.
I can stick to //IGNORE
but i would like to find out which character(s) are causing the problem.
How can i do this?
It was bad idea to work with string as char array (see question comments) because php string type
So we can use
mb_substr
for utf-8 and work with symbols not bytesResult
array(1) { [9]=> string(3) "☺" } string(16) "test bad string"
P.S. The next time I will give a more detailed answer with the code. My mistake