I'm developing a custom module where a user (actually an admin of sorts) can upload a CSV file. Based on the contents of this file, certain rows are inserted into a table.
I'm now having problems with special characters, like é
. These give the following error:
SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xE9initi...' for column 'remarks' at row 1
I've tried changing the collation of the table and of the specific field, but this didn't help. The only thing that did help is changing the encoding of the file. But this puts the burden of solving the problem in the hands of the (non-technical) admin. Something I don't want.
What's more, this used to work. Before this module, things were done with a (non-Drupal) php script. The difference is that the old php script used mysql_query
to insert the records, whereas I am now using db_insert
.
How can I make Drupal/MySql accept the special characters in ANSI?