ivantxo
ivantxo

Reputation: 639

MySQL encodes string and adds a question mark

I'm having a very strange behaviour here.

I copy a table from a PDF, the table is pasted in Excel spreadsheet. Then the .xls file is saved as .csv. Finally, the .csv is uploaded to MySQL trough Php. Some of the text have a hidden question mark at the beginning. Like this one: NEE13. I can't see nothing abnormal, but just to test I did a single insert with phpMyAdmin. MySQL complains saying:

Warning: #1366 Incorrect string value: '\xEF\xBB\xBFNEE...' for column 'rid' at row 1.

The resulting value in the database then is: ?NEE13

Any help to correct this issue is appreciated. Thanks.

Upvotes: 1

Views: 1627

Answers (1)

CyberDem0n
CyberDem0n

Reputation: 15036

Your file begins with 'EF BB BF'. They are called utf8 magic bytes, or BOM (Byte Order Mark).

MySQL can't parse these bytes as correct utf8 symbol and replace they with '?' mark.

Just remove these bytes before insert, or use blob/varbinary field to store your file.

Upvotes: 3

Related Questions