MySQL and PHP Unicode issues

I have the following UTF-8 file exported from Microsoft Access File

http://www.yousendit.com/download/TTZtT214SU84Q1FLSkE9PQ

I have guaranteed my mysql database is utf8 with status; command for client and server. I insert the above file into my database with the following command:

LOAD DATA LOCAL INFILE 'tblAuction1.txt' INTO TABLE Auctions FIELDS TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\';

      

Everything seems to be OK, unicode characters are rendered in the html as they should be as far as I can tell. The direct content of the database field is here:

http://www.nomorepasting.com/getpaste.php?pasteid=22622

However, the resulting HTML is displayed:

http://www.nomorepasting.com/getpaste.php?pasteid=22617

What is displayed as

Listing list

1.00 
<\/OBJECT>
');\n\t\t<\/SCRIPT>\n\t\t

      

in the browser

The code I'm using to show this:

http://www.nomorepasting.com/getpaste.php?pasteid=22618

which worked fine before I changed the encoding.

As a side question, I am wondering why changing from tab delimited to semicolon separator and nested fields ddecrease the size of the exported file by half. A tab character is a single character, like; symbol and adding quotes to enclose should have increased the size?

0


source to share


1 answer


Depending on your web server configuration, you may need to explicitly specify the encoding of "text / html; charset = UTF - 8" header()

:

header('Content-Type: text/html; charset=UTF-8');

      



This should be sufficient for your specific problem, but - if you also intend to manipulate strings - note that PHP contains many functions that are unsafe for use with multibyte characters: you must at least configure the mbstring extension correctly .

I also have a cheatsheet in my bookmarks, I think this is still up to date.

+1


source







All Articles