I am facing a strange issue when extracting data from a MySql database and inserting it in a CSV file. In the database, the field value is the following:
K Secure Connection 1 año 1 PC
fwrite($this->fileHandle, utf8_encode($lineContent . PHP_EOL));
K Secure Connection 1 aÃ±o 1 PC
string(39) "Kaspersky Secure Connection 1 año 1 PC"
var_dump shows that the string is already encoded in UTF-8. Using
utf8_encode on it will garble it (the function attempts a conversion from Latin-1 to UTF-8). You're therefore actually writing "aÃ±o" encoded in UTF-8 into your file, which is then "correctly" picked up by LibreOffice.