tags:

views:

240

answers:

2

I have an UTF-8 encoded txt file and I want to import it to latin1_general_ci table. Problem is that some characters display as ? in database and not as they supposed to.

I tried mb_convert_encoding($str, "ISO-8859-1", "UTF-8"); but that didn't do anything.

What am I doing wrong?

+2  A: 

Latin1 doesn't include all Unicode characters. You can use iconv() with //TRANSLIT option to transliterate unknown characters to their closest latin1 equivalents:

iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text)
jholster
You might also want to determine if you'll need to escape the text for MySQL.
Marcus Adams
A: 

I use utf8_decode, it works for me.

David V.