?Briella 2008-12-10 12:32 采纳率: 0%
浏览 31

MySQL和PHP Unicode问题

I have the following UTF-8 file exported from a microsoft access file

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

I have ensured my mysql database is utf8 with the status; command for both 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 '\\';

All seems to be going kind of OK, unicode characters are displayed in the html as they should be as far as I can tell. The direct contents of the database field is here:

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

However the resulting html code is displayed:

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

Which displays as

Fee Listing

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

in the browser

The code I am using to show this is:

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

which was working fine before I changed the encoding.

as a side question, I am wondering why changing from tab delimited to semicolon delimited, and enclosing fields would ddecrease the size of the exported file by half. The tab character is a single character just like the ; character, and adding quotes to enclose should have increased the size?

  • 写回答

1条回答 默认 最新

  • weixin_33704591 2008-12-10 13:58
    关注

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

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

    This should be enough for your specific problem, but - in case you also intend to manipulate the strings - note that PHP contains many functions that are not safe to use with multi-byte characters: you should at least properly configure the mbstring extension.

    I also have this cheatsheet in my bookmarks, I think it's still relevant.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。