开发者

How to parse string with special characters from database using php?

I had a MySQL database with names of roads in it. There is this one entry that gives me problems when I query it from the database: Osmeña Avenue. I stored the data to the DB using Java, and then I viewed the data using phpMyadmin then I saw 4f736d65c3b161204176656e7565 instead of Osmeña Avenue. When I query for the names, I placed them inside an XML file, which I use for my application. When I query for Osmeña Avenue, my program freezes. I found out that in the XML file, the ñ is replaced by a �, which causes the freeze. First, why do I saw a bunch of numbers in the phpMyAdmin view for Osmeña Avenue? And what can I do to get the right string with the special characters from the database using PHP? Thanks in advance!

EDIT: the 开发者_如何学编程XML file is used to draw routes using OpenLayers.Format.KML;.


4f736d65c3b161204176656e7565 is a sequence of bytes (4f, 73,..) that represent Osme\xc3\xb1a Avenue, which is the UTF-8 representation of Osmeña Avenue.

Just decode your data properly. Inside your app, keep working only with Unicode strings, and encode/decode string data at system edges.


Don't use utf8_bin, use utf8_general instead.

Or, it would be even better to just use latin1_swedish_ci or latin1_swedish_cs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜