0

Am doing a CSV import in laravel, For a few languages, it is not possible to import. The error which I got was

Incorrect string value: '\xFCr M\xE4n...' for column 'product_name_german' at row 1

when i print the line it shows like below text (with a starting character "b") :

b"Laufschuhe für Männer Artikel 001"

Actual text which i give was

Laufschuhe f�r M�nner Artikel 001

The CSV file is utf-8 bom encoded type

manu
  • 351
  • 2
  • 15
  • Obligatory read: https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/ – Loek Feb 28 '19 at 11:45
  • Possible duplicate of [UTF8 mysql encoded database, but not showing special characters in PHP](https://stackoverflow.com/questions/19281747/utf8-mysql-encoded-database-but-not-showing-special-characters-in-php) – MimoudiX Feb 28 '19 at 12:01

2 Answers2

1

Firstly be sure you have this meta in html tag

<meta charset="UTF-8">

You can check also with this line in php, above you mysql extraction

header('Content-type: text/html; charset=utf-8');

If you store your special character in database as html code like this &#39; which is ' when you extract try to use this php function

htmlspecialchars_decode($your_text_from_db);
MimoudiX
  • 612
  • 3
  • 16
0

I think u havent changed charset to utf8, try this : hope it helps #sayNoToWar

$statSQL= 'SET CHARACTER SET utf8'; 

mysqli_query($your_db,$sSQL) 
or die ('charset in DB didn\'t change'); 
Hamza Dastgir
  • 155
  • 1
  • 5