views:

203

answers:

1

I'm following the demo code from article of phpsqlgeocode.html

In the db, I inserted some Chinese addresses, which is utf8 encode. I found after urlencode the Chinese address, the output of the address will be wrong.Like this one:

http://maps.google.com.tw/maps/geo?output=csv&key=ABQIAAAAfG3KxFZXjEslq8VNxMBpKRR08snBovzCxLQZ9DWwpnzxH-ROPxSAS9Q36m-6OOy0qlwTL6Ht9qp87w&q=%3F%3F%3F%3F%3F%3F%3F%3F%3F132%3F

Then output(can't query from php, it have to test as browser url link), 200,5,59.3266963,18.2733433

Whose address is actually located in Taichung Taiwan, but turn out to in Sweden Europe. But when I paste the Chinese address(such as 台中市西屯區智惠 街131巷56號58號60號) in the url, the result turn out to be fine!!!

So my question is how to make sure it send out the original Chiness address?? how to prevent urlencode()??? I found take urlencode() away not change anything.

(I've change the MAPS_HOST from maps.google.com to maps.google.com.tw.) (I'm sure my key is right, and other English address geocoding are fine.)

Thanks!!

A: 
q=%3F%3F%3F%3F%3F%3F%3F%3F%3F132%3F

decodes to:

?????????132?

so something has corrupted the string already before URL-encoding. This could happen if you try to convert the Chinese characters into an encoding that doesn't support Chinese characters, such as Latin-1.

You need to ensure that you're using UTF-8 consistently through your application. In particular you will need to ensure the tables in the database are stored using a UTF-8 character set; in MySQL terms, a UTF-8 collation. The default collation for MySQL otherwise is Latin-1. You'll also want to ensure your connection to the database uses UTF-8 by calling 1mysql_set_charset('utf-8')`.

(I am guessing from your question that you're using PHP.)

bobince